Name validation issue (Php)
<p>I have been trying to create a contact form for a uni project but for some reason, my name validation script is not working, yet the email validation and comments validation works fine. This is my my first time working with php and any help you guys could give would be much appreciated:</p>

<pre><code>   if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['comments'])){
died('We are sorry but there appears to be a problem with the form you submitted.');
}

$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];

    $error_message = "";
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    if(!preg_match($email_exp, $email)){
    $error_message .= 'The Email address you entered does not appear to be valid.&lt;br/&gt;'; 
    }
    $string_exp = "/^[A-Za-z'- ] +$/";
    if(!preg_match($string_exp, $name)){
    $error_message .= 'The name you entered does not appear to be valid.&lt;br/&gt;';
    }
    if(strlen($comments) &lt; 2){
    $error_message .= 'The message you entered does not appear to be valid.&lt;br/&gt;';
    }
    if(strlen($error_message) &gt; 0 ){
    died($error_message);
    }
    $email_message = "Form Details below.\n\n";

function clean_string($string){
$bad = array("content-type", "bcc:", "to:", "cc", "href");
return str_replace($bad, "", $string);
}
$email_message .="Name:" . clean_string($name) . "\n";
$email_message .="Email:" . clean_string($email) . "\n";
$email_message .="Comments" . clean_string($comments) . "\n";
</code></pre>
