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.<br />\nPlease 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.<br />\nPlease 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.<br />\nPlease remove them and repost.";}else{fputs($guestbook, $usermsg);fclose($guestbook);echo "Thx for using this guestbook.<br />";echo "Your Message has been submited.<br />";echo "Go <a href=\"http://localhost/guestbook.html\">here</a> 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";}?>