I've seen several PHP scripts pass variables in the URL, like this:
http://www.mattfaus.com/index.php?var1=value&var2=valueagain&var3=yada3
I know how I would construct the URL with PHP, but all I really need to know is how to get the data from the variables in the URL.
Ok, say I make a page that links to http://www.mattfaus.com/index.php?var1=value&var2=valueagain&var3=yada3 . How do I use the values of var1, var2, and var3 within index.php?
you would reference them by there name
$var1 $var2 $var3
man, that's so easy!!
And the proper syntax is as follows:
/folder/index.php?var1=value&var2=value2
you might also want to read up on $HTTP_ Arrays
http://us2.php.net/variables.predefined
$_GET is an array containing all variables passed through the URL. You SHOULD NOT just refer to them by name ( ie DO NOT do this: $var when you request a URL http://www.domain.com/?var=1 )
Instead use $_GET['var']
$var1 $var2 $var3 [/B]
Security issues and won't work if register_globals are off.
Don't use em!
$GET['var1'] $GET['var2'] $_GET['var3']
Ok, you guys have helped a lot!
conclusion:
URL: www.test.com/folder/index.php?var1=one&var2=2
EQUALS:
$insidescriptvar1 = $_GET['var1']; // returns "one" $insidescriptvar2 = $_GET['var2']; // returns 2