Hello,
Each time, I fill the values on the newbook.html and click the Submit button to add them on the database, the error line “You have not entered all the required details…” which I wrote in insert_book.php executes.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
newbook.html
<html>
<head>
<title>Book-O-Rama - New Book Entry</title>
</head>
<body>
<h1>Book-O-Rama - New Book Entry</h1>
<form action="insert_book.php" method="post">
<table border=0>
<tr>
<td>ISBN</td>
<td><input type=text name=isbn maxlength=30 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>
!!!!!!!!!!!!!!!!!!!!!!!!!!
insert_book.php
<html>
<head>
<title>Book-O-Rama Book Entry Results</title>
</head>
<body>
<h1>Book-O-Rama Book Entry Results</h1>
<?
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", "upretyr1_sqluser", "sql488704");
if (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
mysql_select_db("upretyr1_userInfo");
$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>