The PHP built-in $_POST function is used to collect values in a form (as name says, you do this with the method=”post”) The information send with POST method is invisible to others (the opposite of the GET method.)
Another difference between the $_GET function and the $_POST function is that the $_POST function doesn’t limit the amount of information that you want to send. (Limit of $_GET is 100 characters.) But you should be aware of the following: by default there is an 8Mb maximum size for the post method. (If you want a larger size you can change it in the php.ini file. The setting is called post_max_size.)
Let’s look at an $_POST example:
<html> <body> <form action="test.php" method="post"> Your name: <input type="text" name="yourname" /> <input type="submit" /> </form> </body> </html>
If the user clicks on the submit button, the URL called will look like this:
The names of the form fields will automatically be the keys in the $_POST array. So we can use the name “yourname” in the PHP file test.php. For example we can do this:
Welcome <?php echo $_POST["yourname"]; ?>!
That’s all for this tutorial.