[Solved] those bits in the address bar after .php

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
tom91
Forum Newbie
Posts: 8
Joined: Thu Sep 01, 2005 3:10 pm

[Solved] those bits in the address bar after .php

Post by tom91 »

Hi,
Does anyone know where I can find a tutorial on the bits of code in the address bar after .php ?
E.g. the one I can see now is /posting.php?mode=newtopic&f=1
I can't search for one as I don't know what it's called.

Thanks,
Tom
User avatar
hopfateam
Forum Newbie
Posts: 12
Joined: Sun May 29, 2005 6:30 pm
Location: Germany
Contact:

Post by hopfateam »

http://de2.php.net/manual/en/language.v ... ternal.php should help for basics

Those bits in the adressbar are gathered via $_GET[]
e.g.

url: domain.com/index.php?name=george
Goal: echo out what is transported in "name"

Code: Select all

$valueOfName=$_GET["name"];

echo $valueOfName;
//same as

echo $_GET["name"];
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

quick lesson:

anything after the question mark "?" will be considered variable information by any scripting language. to separate multiple variables the ampersand sign "&" is used.

so say for example I have the following URL:

Code: Select all

http://www.mysite.com/mypage.php?var1=bob&var2=larry
on the page mypage.php, I can do something with those variable names and their corresponding values.

in the case below I'll just echo them out for display:

Code: Select all

echo (isset($_GET['var1']) ? $_GET['var1'] : "Var 1 is not set");
echo (isset($_GET['var2']) ? $_GET['var2'] : "Var 2 is not set");
obviously you can do whatever you want with variables, but as a baseline, that should get you going...
tom91
Forum Newbie
Posts: 8
Joined: Thu Sep 01, 2005 3:10 pm

Post by tom91 »

thanks for your help
Post Reply