View Full Version : getting querystring data in php?
06-23-2005, 08:03 PM
how can i request data from the query string in php??
thanks in advance for your time!
06-23-2005, 09:39 PM
Use $_GET, for instance if your querystring is:
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'].
06-23-2005, 09:41 PM
// If using GET method
$stringl = $_GET["field_name"];
// If using POST method
$stringl = $_POST["field_name"];
06-24-2005, 03:22 PM
ok, is it the same thing for requesting submitted form data?
thanks again for al your help guys!
06-24-2005, 03:26 PM
hmm, i seem to be getting an error when I try to use:
$username = $_GET["username"];
Notice: Undefined index: username in C:\Apache Group\Apache2\htdocs\national\admin\test.php on line 3
am i missing something?
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.
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?
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?
Powered by vBulletin® Version 4.2.2 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.