Jump to content

Recommended Posts

$_GET as the name suggest GET's the value of the variable from the url for instance:

index.php?page=about

$_GET['page'] would have the value of "about."

 

$_POST handles values from the html <form>. So.

<form method="post" action="">
<input type="text" name="about" />
<input type="submit" name="submit" value="Send" />
</form>

Both $_POST['about'] and $_POST['submit'] would have values (usually, you'd use the submit button to check if the form has been submitted.)

or you could use $_REQUEST which will give you values if you have subbmited via a form or by getting params from a URL.

I don't find there to be many instances where you need to use $_REQUEST. In fact, the only situation I've used it in is custom confirm codes for login systems.

or you could use $_REQUEST which will give you values if you have subbmited via a form or by getting params from a URL.

I don't find there to be many instances where you need to use $_REQUEST. In fact, the only situation I've used it in is custom confirm codes for login systems.

 

Strangely enough, that's the only place I've ever used it as well.

or you could use $_REQUEST which will give you values if you have subbmited via a form or by getting params from a URL.

 

You could, but people tend to not do this in that it is a potential security issue. Given that you should know exactly how your data is suppose to be passed to the script, so why have a "catch-all" to retrieve it? Better to code it to your needs. In an instance where you are expecting $_POST or $_GET data, as in confirmation email hashes, $_REQUEST is fine because you expect either or. But if your form is POSTing, you do not want to grab the data from $_REQUEST, because you know it should be posted and this helps "validate" (I use this term loosely as forms are easy to fake) the code and it also helps debugging so you know what form it is potentially coming from etc.

 

Also, $_REQUEST contains more than just the $_POST / $_GET data. It also includes $_COOKIE data, which can be overwritten by $_POST / $_GET(or vice versa see the link below for the order in the 3rd notation) and, as stated above, create a potential security hole in your script. Hence why they have them broken out into separate arrays and why you should stick to using the superglobal array where you expect the data to be coming in from.

 

http://www.php.net/manual/en/reserved.variables.request.php

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.