exe2.html
<html>
<head>
<title> Welcome to book seller</title>
</head>
<body>
<form action="exe2.php"
method="post">
<!--greetings-->
<p><h3>You are welcome</h3></p>
<hr/>
<!--personal information-->
<table>
<tr>
<td><B>please input your name:</B></td>
<td><input type="text" name="name" size="15" /></td>
</tr>
<tr>
<td><B>please input your address:</B></td>
<td><input type="text" name="address" size="15" /></td>
</tr>
<tr>
<td><B>please input your zip:</B></td>
<td><input type="text" name="zip" size="15" /></td>
</tr>
</table>
<hr/>
<!--purchase information -->
<h3>please fill in the quantity field of the following form</h3>
<table border="1">
<caption><h4>purchase information</h4></caption>
<tr>
<td>book</td>
<td>publisher</td>
<td>price</td>
<td>quantity</td>
</tr>
<tr>
<td>Web technology</td>
<td>Springer pres</td>
<td>$5.0</td>
<td><input type="text" name="webnum" size="5"/></td>
</tr>
<tr>
<td>mathematics</td>
<td>ACM press</td>
<td>$6.2</td>
<td><input type="text" name="mathnum" size="5"/></td>
</tr>
<tr>
<td>principle of OS </td>
<td>Science press</td>
<td>$10</td>
<td><input type="text" name="OSnum" size="5"/></td>
</tr>
<tr>
<td>Theory of matrix</td>
<td>High education press</td>
<td>$7.8</td>
<td><input type="text" name="matrixnum" size="5"/></td>
</tr>
</table>
<br/>
<hr/>
<!-- payment method-->
<h3>payment method</h3>
<input type="radio" name="paymet" checked="checked" value="cash" />cash<br/>
<input type="radio" name="paymet" value="cheque"/>cheque<br/>
<input type="radio" name="paymet" value="credit"/>credit card<br/><br/>
<hr/>
<!--submit and reset -->
<input type="submit" value="Submit Order"/>
<input type="reset" value="Clear Order Form"/>
</form>
</body>
</html>
exe2.php
<html>
<head>
<?php
$name=$_POST["name"];
$address=$_POST["address"];
$zip=$_POST["zip"];
$webnum=$_POST["webnum"];
$mathnum=$_POST["mathnum"];
$OSnum=$_POST["OSnum"];
$matrixnum=$_POST["matrixnum"];
$paymet=$_POST["paymet"];
if($webnum=="") $webnum=0;
if($mathnum=="") $mathnum=0;
if($OSnum=="") $OSnum=0;
if($matrixnum=="")$matrixnum=0;
$sum=$webnum+$mathnum+$OSnum+$matrixnum;
$webcost=$webnum*5;
$mathcost=$mathnum*6.2;
$OScost=$OSnum*10;
$matrixcost=$matrixnum*7.8;
$totalcost=$webcost+$mathcost+$OScost+$matrixcost;
?>
</head>
<body>
<h3>customer information</h3>
<table>
<tr><td><B>customer name:</B></td><td><?php print("$name");?></td></tr>
<tr><td><B>customer address:</B></td><td><?php print("$address");?></td></tr>
<tr><td><B>customer zip:</B></td><td><?php print("$zip");?></td></tr>
</table>
<?php if($sum) {?>
<hr/>
<h3>purchase information</h3>
<table border="1")
<tr>
<td>book</td>
<td>publisher</td>
<td>price</td>
<td>total cost</td>
</tr>
<?php } ?>
<?php
if($webnum)
{
print("<tr><td>Web technology</td>");
print("<td>Springer pres</td>");
print(" <td>\$5.0</td>");
printf(" <td>$%5.2f</td></tr>",$webcost);
}
?>
<?php
if($mathnum)
{
print("<tr><td>mathematics</td>");
print("<td>ACM press</td>");
print(" <td>\$6.2</td>");
printf(" <td>$%5.2f</td></tr>",$mathcost);
}
?>
<?php
if($OSnum)
{
print("<tr><td>principle of OS</td>");
print("<td>Science press</td>");
print(" <td>\$10</td>");
printf(" <td>$%5.2f</td></tr>",$OScost);
}
?>
<?php
if($matrixnum)
{
print("<tr><td>Theory of matrix</td>");
print("<td>High education press</td>");
print(" <td>\$7.8</td>");
printf(" <td>$%5.2f</td></tr>",$matrixcost);
}
?>
<?php if($sum) {?></table> <?php } ?>
<br/>
<hr/>
<h3> total information</h3>
<?php
printf("%s has bought %d books<br/>",$name,$sum);
printf("%s paid $%5.2f<br/>",$name,$totalcost);
printf("%s paid by %s",$name,$paymet);
?>
</body>
</html>