PHP MySQL guestbook

hi,

i’ve just followed a tutorial for a mysql guestbook as i was told my other one was far too outdated, thanks to binime for getting it working though. Anyhow, after completing the tut, and getting it looking just how i’d like, i’ve hit a few snags. Firstly adding ‘checkfield’ to stop the form being submitted if any of the the text fields aren’t completed. it seems to show the error message even when the form is filled out in full :

http://www.unearth-online.net/home.php?p=guestbook

here’s the code :

<?

include "gb-database.php";

$name = $_POST["name"];
$email = $_POST["email"];
$rating = $_POST["rating"];
$message = $_POST["message"];
$date = date("F j, Y");
$error = 0;

function checkfield($input)
{
  if(!preg_match ("/^[A-z]+[0-9]+[A-z]+?.@!$%£&*()/",$input) && $input != "")
    return TRUE;
  else
    return FALSE;
}
if	(!checkfield($name));
	(!checkfield($email));
	(!checkfield($message));
	(!checkfield($rating));
{
  echo "One, or more of the fields was not filled out correctly...<br /><br />";
  echo "<a href=\"home.php?p=guestbook\">Click here</a> to go back.";
  $error = 1;
}

if($error == 0){
mysql_select_db($db, $connect);

mysql_query("INSERT INTO comments (name, email, rating, message, date) 
VALUES ('$name', '$email', '$rating', '$message', '$date')");

echo "Thanks for using this guestbook.<br /><br /> <a href=\"home.php?p=guestbook\">Click here</a> to go back.";
}
mysql_close($connect);
?>

I’m also looking to have a new page start after 10 entries but im not sure where to start. if anyone could help me out that’d be great, thanks

:afro: