PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
benthompson
Forum Newbie
Posts: 2 Joined: Sat Jan 29, 2005 6:49 pm
Post
by benthompson » Sat Jan 29, 2005 6:51 pm
Hi people, i would like to know what these things do on the URL
e.g. "index.php?page=home&display=fullnews&id=2664"
i have noticed these quite often on php and other languages and would like to know what they are used for and why they are there.
If possible please link me to a guide on them aswell
Thanks alot !
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Jan 29, 2005 6:56 pm
they are "get" request variables.
their meaning varies wildly between page implementations, as you, the programmer, can control what inputs you listen to, if any at all.
In your example request, it would appear to be requesting the standard home page to display full length (or details) of news with the id of 2664.
hunterhp
Forum Commoner
Posts: 46 Joined: Sat Jan 22, 2005 5:20 pm
Contact:
Post
by hunterhp » Sat Jan 29, 2005 8:59 pm
index.php?page=games
would be the same as writting
<?
$page = 'games';
?>
When you write page=games&game=halo
It would equal
<?
$page = 'games';
$game = 'halo';
?>
If a variable is set however, page or game will not be changed. Example...
<?
$page = 'index';
?>
If someone goes to
http://www.yoursite.com/index.php?page=games , it won't change the 'index' value it already has, so make sure to understand this.
That's pretty much it/all I know about these type of variables.
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Sat Jan 29, 2005 10:22 pm
This is commonly used, as you can see in your own example, to request pages be loaded on your index.
For example
index.php?page=home
and on index.php you would find
Code: Select all
if (!@include($_GETї'page'].'.php'))
{
echo '404: Page not found';
}
That is obviously a simplified version, but I hope you get the point
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Jan 29, 2005 10:50 pm
hunterhp's example only works when register_globals is on, which it shouldn't be. (security issue)
benthompson
Forum Newbie
Posts: 2 Joined: Sat Jan 29, 2005 6:49 pm
Post
by benthompson » Sun Jan 30, 2005 8:38 am
This is all great stuff, thanks alot for the reply guys