The process starts by calling "last_ID.php", which on SUBMIT calls "last_ID2.php" the code for these are as follows:
ps. The logging into the database is done through the include: include ("test_holding_inc.php");
last_ID.php
Code: Select all
<html>
<body>
<center><b> Place a book order</b></center><br></br>
<?php
# last_ID.php
# include file
echo "<FORM METHOD=GET ACTION="last_ID2.php">";
echo "Please select a book:";
echo "<SELECT> NAME="book">";
echo "<OPTION>Web admin";
echo "<OPTION>Shell programming";
echo "<OPTION>Linux security";
echo "<OPTION>Posix programming";
echo "<OPTION>Apache admin";
echo "<OPTION>Networking Linux";
echo "</SELECT>";
echo "Select the quantity";
echo "<SELECT> NAME="qty">";
echo "<OPTION>1";
echo "<OPTION>2";
echo "<OPTION>3";
echo "<OPTION>4";
echo "<OPTION>5";
echo "</SELECT>";
echo "<BR></BR><BR></BR>";
echo "<INPUT TYPE="SUBMIT" VALUE="Place order!">";
echo "<INPUT TYPE="RESET" VALUE="Clear!">";
?>
</FORM>
</BODY>
</HTML>Code: Select all
<html>
<body>
<?php
# last_ID2.php
# include file
include ("test_holding_inc.php");
$book=$_GETї'book'];
$qty=$_GETї'qty'];
$sql="INSERT INTO linux_books(book,qty) VALUES ('$book','$qty')";
if (!mysql_query($sql,$connection)) {
echo "Error cannot add record..hit the back button and try again!!!<BR>";
exit;
} else {
# insert OK inform user and get the last insert ID
$ID=mysql_insert_ID();
echo "Order taken ї".mysql_affected_rows()."] record added<BR>";
echo "Details are<BR>Book: <B>$book</B><BR>Qty:<B>$qty</B><BR>";
echo "For your reference the order number is:ї<B>$ID</B>]";
}
echo "<BR><A HREF="last_ID.php"> Back</A>";
?>
</BODY>
</HTML>