if ($_POST['name'] != "" && $_POST['msg'] != "")
{
if (!preg_match("<>", $_POST['name']) && !preg_match("/^[-0-9A-Z_@\s]+$/i", $_POST['msg']))
{
echo "Contains invalid characters. Go back and fix it";
}
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($_POST['name'] == "" && $_POST['msg'] != "")
{
echo "Please fill the name field";
}
elseif($_POST['name'] != "" && $_POST['msg'] == "")
{
echo "Please fill the message field";
}
else{
echo "Please fill both of the fields and then submit";
}
?>