Ok,
change part of the code:
// Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){
// Validate the entries
$validator = new Validator();
$validator->validateGeneral($HTTP_POST_VARS['title'],'Book Title');
$validator->validateGeneral($HTTP_POST_VARS['author'],'Author');
$validator->validateGeneral($HTTP_POST_VARS['date'],'Date');
$validator->validateGeneral($HTTP_POST_VARS['time'],'Time');
// Check whether the validator found any problems
if ( $validator->foundErrors() ){
echo 'There was a problem with: <br>'.$validator->listErrors('<br>'); // Show the errors, with a line between each
} else {
// Create an SQL query (MySQL version)
// The 'addslashes' command is used 5 lines below for added security
// Remember to use 'stripslashes' later to remove them (they are inserted in front of any
// special characters
$insertQuery = "INSERT INTO bookclub (title, author, date, time) VALUES ('"
.$HTTP_POST_VARS['title']."', '"
.$HTTP_POST_VARS['author']."', '"
.$HTTP_POST_VARS['date']."', '"
.$HTTP_POST_VARS['time']."')";
// Save the form data into the database
if ($result = $connector->query($insertQuery)){
// It worked, give confirmation
echo '<center><b>Article added to the database</b></center><br>';
} else {
// It hasn't worked so stop. Better error handling code would be good here!
exit('<center>Sorry, there was an error saving to the database: '.mysql_error().'</center>');
}
}
}
I just noticed that you're using but never setting $insertQuery.
EDIT: This is the first step, the script still needs some tweaking ...
Thomas