if (!empty($_POST['name']) && !empty($_POST['msg']))
{
if (ereg('[^A-Za-z0-9 ]', $_POST['name']) && ereg('[^A-Za-z0-9 ]', $_POST['msg']))
{
echo "You are allowed to use only numbers and letters.
\n
Please remove all illegal characters from both name and message field and repost.";
}
elseif(!ereg('[^A-Za-z0-9 ]', $_POST['name']) && ereg('[^A-Za-z0-9 ]', $_POST['msg']))
{
echo "Your message contains illegal characters.
\n
Please remove them and repost.";
}
elseif(ereg('[^A-Za-z0-9 ]', $_POST['name']) && !ereg('[^A-Za-z0-9 ]', $_POST['msg']))
{
echo "Your name contains illegal characters.
\n
Please remove them and repost.";
}
else{
fputs($guestbook, $usermsg);
fclose($guestbook);
echo "Thx for using this guestbook.
";
echo "Your Message has been submited.
";
echo "Go here to view your message";
}
}
elseif(empty($_POST['name']) && !empty($_POST['msg']))
{
echo "Please fill the name field";
}
elseif(!empty($_POST['name']) && empty($_POST['msg']))
{
echo "Please fill the message field";
}
else{
echo "Please fill both of the fields and then submit";
}
?>