Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

POST .. REQUEST OR GET??? 1

Status
Not open for further replies.

KryptoS

Programmer
Joined
Feb 7, 2001
Messages
240
Location
BE
Hey,

What's the difference between POST, REQUEST and GET? And when do I use POST, when REQUEST and when GET?


greetz

The One And Only KryptoS
 
This is not a PHP question. It's an HTML question. But I'll answer.

I'm unfamiliar with REQUEST in the same context of POST and GET.

POST and GET are both ways of sending data to an application through a web browser. The difference between them is the way in which the browser sends the data to the web server, and how the web server gets the data to the application.

A GET-method form sends the data in the URL. Given an HTML form of:
<form method=&quot;GET&quot; action=&quot;foo.php&quot;>
<input type=&quot;text&quot; name=&quot;bar&quot;>
<input type=&quot;submit&quot;>
</form>

Then when you place a value in the input &quot;bar&quot; and submit the form, you will see the browser go to a site like &quot; The web server then takes that URL and makes the values available to the web application in the form of environment variables. Since on most operating systems, environment variables are limited in size, so is the amount of data you can submit using the POST method. Also, it clutters up the URL.


A POST-method form sends its data to the web server in a stream of data. The web server then makes this stream of data available to the web application. Since a data stream can be as long as it needs to be, there is no technical limit to the amount of data you can send via POST-method input.


Want the best answers? Ask the best questions: TANSTAAFL!!
 
ok sorry, maybe my question was not that good. I want to know when you use $_POST['var'], $_REQUEST['var'] or $_GET['var') ... because, it seems to me that you can use them when you like ... or am I wrong?

The One And Only KryptoS
 
REQUEST is a combination of POST, GET and COOKIE and was introduced in 4.1.0. Since 4.3.0 it also includes FILES.

It seems like a good idea, however, I believe that adressing the correct superglobal arrays makes the code clearer.
Code:
$_REQUEST['myVar']
seems too ambiguous to me. Was it posted or a GET var? Is a cookie set with that var? These seem to be questions I don't want to ask - especially keeping in mind that we do not want arbitrary sources of input.
 
But as far as the rest of the question goes, you use $_POST with POST-method forms and $_GET with GET-method forms.

And I agree with DRJ478. You're much better off leaving $_REQUEST alone, for the same reason you're more secure leaving register_globals set to &quot;off&quot;. (
Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top