Jump to content

Archived

This topic is now archived and is closed to further replies.

Stuve

Help!!

Recommended Posts

Can someone help me what's the diffrens in using:

$_GET[]
$_POST[]
$_REQUEST[]

??

Share this post


Link to post
Share on other sites
$_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....

Share this post


Link to post
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...

Share this post


Link to post
Share on other sites

×

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.