with the little understanding of php wht i hav understood is that.. we use request whn v use certain data frm the same page and use the database.. in case of post v use it whn v hav to get the data frm a different page.. forget get for the time being.... how far is my conception right??????????????/

Recommended Answers

All 5 Replies

Um a little skewed.

Heres the breakdown:
You have a number of "SUPER GLOBALS" in php which are superglobals because they can be accessed from anywhere in the scope of your script. The 3 i'm gonna focus on here are $_POST, $_GET, and $_REQUEST because they are relevant to your question.

$_GET: is an array of all your "GET" variables, these include all the variables which are appended to the url of the page you are trying to access: e.g: index.php?getvar=value
You can then access the variable as follows:

$mygetvar = $_GET['getvar'];

$mygetvar will now be set to "value".
. As well as any data coming from a form whose method is set to get (as opposed to post).

$_POST: is much the same except that you cannot "post" data by appending the variables to the url, they all come from fields nested in a form whose method is set to "post".

$_REQUEST: is sort of a combination of the two, any vars in either $_GET or $_POST will appear in $_REQUEST. However, most experienced programmers will warn you against using this for various reasons, rather just stick to $_GET and $_POST.

As for the page to which the data is sent, that is controlled by your form's action attribute, or your link's href attribute (which you can use to send "get" variables)

Hope I helped clear up your dilemma, if you are still confused checkout php.net

$_REQUEST: is sort of a combination of the two, any vars in either $_GET or $_POST will appear in $_REQUEST. However, most experienced programmers will warn you against using this for various reasons, rather just stick to $_GET and $_POST.

$_REQUEST Also includes $_COOKIE .

$_REQUEST Also includes $_COOKIE .

thanks ShawnCplus.. so do u advice all newbies to use $_GET instead of $_REQUEST... and use it in the same way as $_REQUEST.

thanks ShawnCplus.. so do u advice all newbies to use $_GET instead of $_REQUEST... and use it in the same way as $_REQUEST.

Well, not only get but use $_GET, $_POST, and $_COOKIE separately. Also, never mix REQUEST and the others. Even though REQUEST contains the data it is treated as a separate variable so modifying GET/POST/COOKIE doesn't change REQUEST. Also, it should be noted that using REQUEST can possibly introduce some very hard-to-debug bugs since if you have a GET variable named SomeVar and a POST variable named SomeVar they will override each other (the one winning being determined by the request_order PHP ini setting)

thanks shawncplus...........certain things seemed like tough-to -grab.........bt thanks ..........i will keep that in mind.........

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.