PHP » Predefined Variables » POST variables


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.


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


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

Whatever you posted to the page.

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: