PHP Presentation 3 (PHP Forms)
PHP Presentation 3 (PHP Forms)
PHP Forms
HTML FORM
<html>
<body>
<form action="welcome.php" method="POST">
Enter your name: <input type="text" name="name" >
Enter your age: <input type="text" name="age" >
<input type="submit" >
</form>
</body>
</html>
PHP Script
<html>
<body>
Welcome <?php echo $_POST[‘name’]; ?>.<br >
You are <?php echo $_POST[‘age’]; ?> years old!
</body>
</html>
Here is how it works:
Note: If the method attribute of the form is GET, then the form
information will be set in $_GET instead of $_POST.
HTML (“sample1.html”)
OUTPUT OF EXAMPLE 1
PHP (“welcome.php”)
Example 2
ORDER.HTML
Example 2
ORDER.PHP
OUTPUT OF EXAMPLE 2:
HTML (“order.html”)
OUTPUT OF EXAMPLE 2:
PHP (“order.php”)