I have an html form. I fill in the form data it inserts into the database fine.
If I hit the back button and fill in the data again, it doesn't insert and I get an error message. I clear the cache close the browser. Still same problem. Until randomly it works once then same problem again. What am I doing wrong?
Thanks for your help...
Form code
<form action="insert_book2.php" method="post">
<table border="0">
<tr>
<td>raceID</td>
<td><input type="text" name="raceID" maxlength="13" size="13"></td>
</tr>
<tr>
<td>userID</td>
<td> <input type="text" name="crewmember2" maxlength="30" size="30"></td>
</tr>
<tr>
<td>crewID</td>
<td> <input type="text" name="crewID" maxlength="60" size="30"></td>
</tr>
<tr>
<td>typeOfCanoe $</td>
<td><input type="text" name="typeOfCanoe" maxlength="7" size="7"></td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Register"></td>
</tr>
</table>
</form>
php
<?php require_once('../Connections/dbconn.php');?>
<html>
<head>
</head>
<body>
<h1>Book-O-Rama Book Entry Results</h1>
<?php
// create short variable userIDs
//if error messages occur check data adding. singular numerals seem to cause errors???
$raceID=$_POST['raceID'];
if (!$raceID ) {
echo "You have not entered all the required details.<br />"
."Please go back and try again.";
exit;
}
if (!get_magic_quotes_gpc()) {
$raceID = addslashes($raceID);
}
//need to specify fields that you are inserting the data into when it is autoincrement?
$query = "INSERT INTO crewmembers (raceID) values
('$raceID')";
$result = $db->query($query);
if ($result) {
echo $db->affected_rows." data inserted into database.";
} else {
echo "An error has occurred. The item was not added.";
}
$db->close();
?>
</body>
</html>