php?page... what's this ?

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

Post Reply
benthompson
Forum Newbie
Posts: 2
Joined: Sat Jan 29, 2005 6:49 pm

php?page... what's this ?

Post 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 :wink:

Thanks alot !
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
hunterhp
Forum Commoner
Posts: 46
Joined: Sat Jan 22, 2005 5:20 pm
Contact:

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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&#1111;'page'].'.php'))
&#123;
     echo '404: Page not found';
&#125;
That is obviously a simplified version, but I hope you get the point
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hunterhp's example only works when register_globals is on, which it shouldn't be. (security issue)
Jim_Bo
Forum Contributor
Posts: 390
Joined: Sat Oct 02, 2004 3:04 pm

Post 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
benthompson
Forum Newbie
Posts: 2
Joined: Sat Jan 29, 2005 6:49 pm

Post by benthompson »

This is all great stuff, thanks alot for the reply guys :D
Post Reply