Iwant to make a contact us script and here is done so far. I am almost sure its about preg match filters but cant find a solution why it doesnt work. Appreciate any help. Here is my code:
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$email_from = $_POST['email'];
$comments = $_POST['comments'];
$emailtrue = '/^([A-Za-z0-9-_]+@[A-Za-z0-9-_]+\.[A-Za-z]{2,4})$/';
$nametrue = "/^[A-Za-z]+$/D";
if(!preg_match($nametrue,$first_name)) {
echo "The First Name you entered does not appear to be valid.";
die (); }
if(!preg_match($nametrue,$last_name)) {
echo "The Last Name you entered does not appear to be valid.";
die (); }
if(!preg_match($emailtrue,$email_from)) {
echo "The Email Address you entered does not appear to be valid.";
die (); }
if(strlen($comments) < 4) {
echo "The Comments you entered do not appear to be valid. Min. 4 letters." ;
die (); }
$to = xxxxxxxxxx.com';
$subject = 'User Email';
$headers = 'From: '.$email_from. "\r\n" .
'Reply-To: '.$email_from. "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $comments, $headers);