Skip to main content
GameDev.net gamedev.net
🔒 Locked 🤖 Godot

[web] need a simple php script

Started by Fixxer Sep 3, 2007 at 1:58 PM 7 replies 2.5k views
Original Post
Fixxer
Fixxer
can anyone post a php script that includes the page that id is set to in the url? If its not defined, it includes home.php, else it includes $id. And then links around the site are for example index.php?id=news
deadimp
deadimp
You've just explained the hard part of all that. All you need to do is implement it, it should be difficult since you already have your design.
You can see an example in Thacmus, using the Source page in the thacmus section. Look at how Page works in main.php (look at Page::find()), how it's defined in page.php, and how it's handled in content.php.
Remember, that's just one implementation. There's plenty of others if you don't like one particular solution.
Projects:> Thacmus - CMS (PHP 5, MySQL)Paused:> dgi> MegaMan X Crossfire
Fixxer
Fixxer
Well I used to use this one line of code when I used to do a lot of web design but I have forgotten how to do it, it basically looked like

if not defiend id then include home.php else include id.php
I dont know the syntax for php.

I just had a note pad with a few simple scripts I liked to use.
BarefootSanders
BarefootSanders
Hey,

if you are trying to extract the value of "id" out of the url this is how you would do it:

$id= $_GET['id'];

the item in '' should be equal to whatever you are looking to extract out of the url.

Hope this helps.
BarefootSanders
ToohrVyk
ToohrVyk
[source lang='php']// For security reasons, never include a file that the user specifies// without checking that it's safe.$allowed = array('news', 'contact');$wanted = $_GET['id'];if (!isset($wanted))   require_once('home.php');else if (in_array($wanted,$allowed))  require_once("$wanted.php");else  print "You may not access this file!";
Jonny_S
Jonny_S
[edit]
The poster above has a better solution :D.
Fixxer
Fixxer
Can someone fix my syntax?
I know it looked exactly like this... in theory, the syntax is wrong.

ToohrVyk
ToohrVyk
The correct version is, like, two posts above yours... perhaps you should try to actually read the answers to your threads.

if (!isset($id))   require_once('home.php') else   require_once("$id.php");
Fixxer
Fixxer
I tried that and I get a blank white page.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.