Payne's PHP Notes

Back to Payne's PHP Notebook.

5. Functions and Form Handling

Function:

Form Handling:

POST Method

Source Code Output
<form action="action.php" method="post">
Input <input type="text" name="input" />
<input type="submit" />
</form>
Input
<!-- action.php -->

<html>
<body>

<p>
Input is <b><?php echo $_POST["input"]; ?></b>.
</p>

<p><a href=".">Return</a></p>

</body>
</html>

GET Method

Source Code Output
<form action="action.php" method="get">
Input <input type="text" name="getInput" />
<input type="submit" />
</form>
Input
<!-- getAction.php -->

<html>
<body>

<p>
Input is <b><?php echo $_GET["getInput"]; ?></b>.
</p>

<p><a href=".">Return</a></p>

</body>
</html>
 

$_REQUEST Variable

The $_REQUEST variable can retrieve information through GET, POST, or COOKIE methods.