You are on page 1of 1

Chapter 1.

Web Techniques

1.1 Processing Forms


It's easy to process forms with PHP, as the form parameters are available in the $_GET and
$_POST arrays.
1.3.3. Self Processing form
One PHP page can be used to both generate a form and process it.
<html>
<head> <title> SELF PROCESSING FORM </title> </head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="GET">
<center> Simple Calculator for Addition<br>
<b>Enter the first number</b> <input type="text" name="num1"><br>
<b>Enter the second number</b> <input type="text" name="num2"><br>
<input type="submit" name=add value="Addition">
</form>
<?php
if($_GET['add']=="Addition")
{
$num1=$_GET['num1'];
$num2=$_GET['num2'];
$add=$num1+$num2;
echo "<br> <input type=text value=$add>";
}
?>
</body>
</html>

You might also like