Page 1 of 1
[Solved] those bits in the address bar after .php
Posted: Thu Sep 01, 2005 3:17 pm
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
Posted: Thu Sep 01, 2005 3:33 pm
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"];
Posted: Thu Sep 01, 2005 3:41 pm
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...
Posted: Fri Sep 02, 2005 2:01 am
by tom91
thanks for your help