The $_POST variable is used to collect values from a form with method=”post”. Information sent from a form with the POST method is invisible to others and has no limits on the amount of information to send.
The $_POST variable is used to collect values from a form with method=”post”.
The $_POST variable is an array of variable names and values sent by the HTTP POST method.
Example
<form action=”chi1.php” method=”post”>
Enter your name: <input type=”text” name=”name” />
Enter your Dob: <input type=”text” name=”Dob” />
<input type=”OK” />
</form>
The “chi1.php” file can now use the $_POST variable to catch the form data (notice that the names of the form fields will automatically be the ID keys in the $_POST array):
hi <?php echo $_POST["name"]; ?>.<br />
your <?php echo $_POST["Dob"]; ?> how old!
Why make use of $_POST?
A Variables have no length limit
B Variables sent with HTTP POST are not shown in the URL
yet, because the variables are not displayed in the URL, it is not possible to bookmark the page.
The $_REQUEST Variable
The PHP $_REQUEST variable contains the contents of both $_GET, $_POST, and $_COOKIE.
The PHP $_REQUEST variable can be used to get the result from form data sent with both the GET and POST methods.
Example
hi <?php echo $_REQUEST["name"]; ?>.<br />
your <?php echo $_REQUEST["Dob"]; ?> how old!
You must be logged in to post a comment.