Stuve Posted August 16, 2006 Share Posted August 16, 2006 Can someone help me what's the diffrens in using:$_GET[]$_POST[]$_REQUEST[]?? Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted August 16, 2006 Share Posted August 16, 2006 $_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.... Quote Link to comment Share on other sites More sharing options...
GoinNuts Posted August 16, 2006 Share Posted August 16, 2006 $_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... Quote Link to comment Share on other sites More sharing options...
Stuve Posted August 16, 2006 Author Share Posted August 16, 2006 Thanx !! :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.