POST is the alternative to GET. It sends data “invisibly” – your browser transmits the information from the form to the server behind the scenes, without appending it to the URL. POST can be used to send much larger amounts of data than GET, it will be more secure to send sensitive data but the results of the form action can not be bookmarked.
Variables sent to a PHP script using the POST method are made available to your program as items in the $_POST global array.
You can print out the content of $_POST to have a look at what the form has sent to your server:
a simple form:
1 2 3 4 5 |
<form method="post" action="processForm.php"> <p>username: <input type="text" name="username" value=""/></p> <p>password: <input type="password" name="password" value=""/></p> <p><input type="submit" value="send"/></p> </form> |
access POST parameters using $_POST:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<?php #processForm.php echo "<pre>"; print_r($_POST); echo "</pre>"; /* Array ( [username] => john [password] => topsecret ) */ ?> |