...

View Full Version : getting querystring data in php?



angst
06-23-2005, 08:03 PM
hello!

how can i request data from the query string in php??

thanks in advance for your time!
-Ken

delinear
06-23-2005, 09:39 PM
Use $_GET, for instance if your querystring is:

www.domain.com?id=bob&level=admin
You can access the qs values via $_GET['id'] and $_GET['admin'].

Alternatively, if you're just wanting to grab the entire querystring as a string you can do so using $_SERVER['QUERY_STRING'].

jasong
06-23-2005, 09:41 PM
// If using GET method
$stringl = $_GET["field_name"];
// If using POST method
$stringl = $_POST["field_name"];

angst
06-24-2005, 03:22 PM
ok, is it the same thing for requesting submitted form data?


thanks again for al your help guys!

-SiX

angst
06-24-2005, 03:26 PM
hmm, i seem to be getting an error when I try to use:

$username = $_GET["username"];

gives me:
Notice: Undefined index: username in C:\Apache Group\Apache2\htdocs\national\admin\test.php on line 3

am i missing something?

-SiX

delinear
06-24-2005, 03:54 PM
If you're using the GET form method then it should be the same. If you want to use the POST form method, same thing but use $_POST['username'] instead.

angst
06-24-2005, 04:51 PM
ok, but i'm getting an error for some reason when i do it, as i posted right above your post, do you have any idea what i've done wrong?

thanks again!

-SiX

delinear
06-24-2005, 10:45 PM
You should only be getting that error if the data wasn't properly passed from one page to the other, it's basically saying that it can't find a variable in $_GET/$_POST (whichever you're using) with the name specified.

Which method are you using to submit your data?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum