Tutorial for $_REQUEST in Super Global Variables

What is $_REQUEST?

$_REQUEST is a super global variable that’s used to collect data when an HTML form is submitted. Because $_POST and $_GET accomplish the same purpose and are extensively used, $_REQUEST is rarely used.

Global Variables - Superglobals Several predefined variables in PHP are  "superglobals", which means that they are always accessible, regardless of  scope. - ppt download

Example:- A form with an input field and a submit button is shown in the example below. The form data is delivered to the file provided in the action element of the form> tag when a user submits the data by clicking “Submit.” For processing form data, we point to this file in our example. Replace it with the filename of your choosing if you want to process form data with another PHP file. The value of the input field may then be collected using the super global variable $_REQUEST:

Output:-

Empty box
Just fill some data
After Clicking on submit button it shows this result

We’ve constructed a form in the above code that accepts the user’s name as input and prints it when the submit button is pressed. Because we alter the data on the same page using PHP code, we transfer the data received in the form to the same page using the $_SERVER[‘PHP SELF’] element as stated in the action attribute. The $_REQUEST super global array variable is used to obtain the data.

Latest posts by Ashwani K (see all)
Tagged : / / / / / / / / / /