Jump to content

Help!!


Stuve

Recommended Posts

$_GET[] is an array of data sent to the current script from the previouse html page via the get method header (when the method of your form is method="get".

Same for $_POST[] but form method="post"

$_REQUEST[] is an array containing values from either of these methods - I do use it sometimes but very rarely....
Link to comment
Share on other sites

$_GET is used when what you are looking for is in the querystring.

$_POST is used when what you are looking for is passed using the POST method of the form the data was sent from.

$_REQUEST wraps both $_GET and $_POST, and some other things too.

Now, for a bit of an explanation: When you use the POST method in your form, like this:
[code]<form name="myForm" action="handleMyForm.php method=[color=red]"POST"[/color]
<input type="text" name="myInput">
<input type="submit" name="submit" value="Submit">
</form>[/code]
you should use the $_POST syntax in the script handling the form:
[code]...
$myInput = $_POST['myInput'];
...[/code]

Likewise, if you use the GET method in the form, you should use the $_GET syntax in the form handling script.

$_REQUEST will find both GETs and POSTs, but you should really stick with $_GET or $_POST. If you must use $_REQUEST, and if a GET value and a POST value both have the same name attribute on the form, the variable will be overwritten. The order of precedence is specified in php.ini. I'll leave it as an excercise to you to find the line in the ini file, and learn what the default order of precedence is.

Hope this helps...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.