Page 1 of 1
php?page... what's this ?
Posted: Sat Jan 29, 2005 6:51 pm
by benthompson
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 !
Posted: Sat Jan 29, 2005 6:56 pm
by feyd
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.
Posted: Sat Jan 29, 2005 8:59 pm
by hunterhp
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.
Posted: Sat Jan 29, 2005 10:22 pm
by John Cartwright
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
Posted: Sat Jan 29, 2005 10:50 pm
by feyd
hunterhp's example only works when register_globals is on, which it shouldn't be. (security issue)
Posted: Sun Jan 30, 2005 1:18 am
by Jim_Bo
Hey,
Link to a tutorial that will give you a basic insite to how that type of url is created and the functions behind the urls ..
http://www.phpfreaks.com/tutorials.php? ... l&tut_id=1
Posted: Sun Jan 30, 2005 8:38 am
by benthompson
This is all great stuff, thanks alot for the reply guys
