PHP » Predefined Variables » POST variables

Syntax:
$_POST

Forms are often used together with the HTTP POST method to send variables from one page to another. The $_POST autoglobal contains the variables posted to the current page.

Examples

Code:
<form method = "post">
<input type="text" name="my_var" size="20" maxlength="100" value="">
<input type = "submit" value = "Reload">
</form>
<br>

<?php

@print "Data: " . $_POST["my_var"];

?>
Output:
Whatever you posted to the page.
Explanation:

This is an example of how a form can be used to post data to a page, and how that data can be accessed. A text field and a button are shown. When the button is pressed, the data in the text field is posted back to the same page and printed.

See Also: