Jump to content


Photo

Help!!


  • Please log in to reply
3 replies to this topic

#1 Stuve

Stuve
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 16 August 2006 - 11:14 PM

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

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

??

#2 ToonMariner

ToonMariner
  • Members
  • PipPipPip
  • Advanced Member
  • 3,342 posts
  • LocationNewcastle upon Tyne, UK

Posted 16 August 2006 - 11:27 PM

$_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....
follow me on twitter @PHPsycho

#3 GoinNuts

GoinNuts
  • New Members
  • Pip
  • Newbie
  • 4 posts
  • LocationLiberty, MO, USA

Posted 16 August 2006 - 11:32 PM

$_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:
<form name="myForm" action="handleMyForm.php method=[color=red]"POST"[/color]
<input type="text" name="myInput">
<input type="submit" name="submit" value="Submit">
</form>
you should use the $_POST syntax in the script handling the form:
...
$myInput = $_POST['myInput'];
...

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...

#4 Stuve

Stuve
  • New Members
  • Pip
  • Newbie
  • 8 posts

Posted 16 August 2006 - 11:33 PM

Thanx !!  :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users