Category: web

PHP, handling forms

HTML form, which calls a seperate php file, called action.php:

[html collapse=”false”]
<form action="action.php" method="post">
<p>Your name: <input type="text" name="name" /></p>
<p>Your age: <input type="text" name="age" /></p>
<p><input type="submit" /></p>
</form>
[/html]

The contents of action.php:

[php collapse=”false”]
Hi <?php echo htmlspecialchars($_POST[‘name’]); ?>.
You are <?php echo (int)$_POST[‘age’]; ?> years old.
[/php]

Your name:

Your age:

 

From: A simple tutorial