Задача 22
<html><head><title> Auto Parts</title></head><body>
<h1> Auto Parts</h1><h2>Order Form</h2>
<form action="processorder.php" method=post><table border=0>
<tr><td width=150>Item</td><td width=15>Quantity</td></tr>
<tr><td>Tyres</td><td <input type="text" name="tyreqty" size=3 maxlength=3></td></tr>
<tr><td>Oil</td><td><input type="text" name="oilqty" size=3 maxlength=3></td></tr>
<tr><td colspan=2 align=center><input type=submit value="Submit Order"></td></tr>
</table></form></body></html>
Задача 23
<html><head><title> Auto Parts: Order Results</title></head><body>
<h1>Auto Parts</h1><h2>Order Results</h2>
<?
echo "<p>Order processed at "; // Start printing order
echo date("H:i, jS F");
echo "<br><p>Your order is as follows: <br>";
echo $tireqty." tires<br>";
echo $oilqty." bottles of oil<br>";
$totalqty = 0; $totalamount = 0.00;
define("TYREPRICE", 100); define("OILPRICE", 10);
$totalqty = $tyreqty + $oilqty;
$totalamount = $tyreqty * TYREPRICE + $oilqty * OILPRICE;
$totalamount = number_format($totalamount, 2);
echo "<br>\n Items ordered: ".$totalqty."<br>\n";
echo "Subtotal: $".$totalamount."<br>\n";
$taxrate = 0.10; // local sales tax is 10%
$totalamount = $totalamount * (1 + $taxrate);
$totalamount = number_format($totalamount, 2);
echo "Total including tax: $".$totalamount."<br>\n";
?></body></html>
Задача 24
<html><head>
<title> Auto Parts - Customer Orders</title></head><body>
<hl> Auto Parts</hl> <h2>Customer Orders</h2>
<?
@$fp = fopen("$DOCUMENTROOT/../orders/orders.txt" , "r");
if (!$fp) {
echo "<p><strong>No orders pending."
."Please try again later.</strong></p></body></html>";
exit; }
while (!feof($fp)) {
$order= fgets($fp, 100);
echo $order."<br>"; }
fclose($fp); ?>
</body> </html>
Задача 25
<html><head><title>Book Catalog Search</title> </head><body>
<hl>Book Catalog Search</hl>
<form action="results.php" method="post"> Choose Search Type:<br>
<select name="searchtype">
<option value="author">Author
<option value="title">Title
<option value="isbn">ISBN </select> <br>
Enter Search Term:<br> <input name="searchterm" type=text> <br>
<input type=submit value="Search"> </form>
</body> </html>
Задача 26
<html><head><title>Book - New Book Entry</title> </head> <body>
<hl>Book- New Book Entry</hl>
<form action="insert_book.php" method="post"> <table border=0>
<tr><td>ISBN</td><td><input type=text name=isbn maxlength=13 size=13><br></td> </tr>
<tr><td>Author</td><td> <input type=text name=author maxlength=30 size=30><br></td> </tr>
<tr><td>Title</td><td> <input type=text name=title maxlength=60 size=30><br></td> </tr>
<tr><td>Price $</td><td><input type=text name=price maxlength=7 size=7><br></td> </tr>
<tr><td colspan=2><input type=submit value="Register"></td></tr>
</table>
</form></body></html>
Задача 27
<html><head><title> Book Entry Results</title></head> <body>
<hl> Book Entry Results</hl>
<?
if (!$isbn || !$author || !$title || !$price)
echo "You have not entered all the required details .<br>"
."Please go back and try again."; exit ; }
$isbn = addslashes($isbn);
$author = addslashes($author);
$title = addslashes($title) ;
$price = doubleval($price);
@$db = mysql_pconnect("localhost", "bookorama", "bookorama");
if (!$db) {
echo "Error: Could not connect to database. Please try again later."; exit;}
mysql_select_db ("books");
$query = "insert into books values
('".$isbn."', '".$author."', ' ".$title."', '".$price."')";
$result = mysql_query($query);
if ($result)
echo mysql_affected_rows()." book inserted into database.";
?>
</body> </html>