home

Php Post Tutorial


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:

    <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:

<?php #processForm.php
echo "<pre>";
print_r($_POST);
echo "</pre>";

/*
Array
(
[username] => john
[password] => topsecret
)
*/

?>

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Copyright © 2014 by Cramerz.com.