gsencan Posted January 24, 2012 Share Posted January 24, 2012 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); Quote Link to comment https://forums.phpfreaks.com/topic/255653-php-send-email-script/ Share on other sites More sharing options...
AyKay47 Posted January 24, 2012 Share Posted January 24, 2012 What actually happens when the code is ran? Quote Link to comment https://forums.phpfreaks.com/topic/255653-php-send-email-script/#findComment-1310534 Share on other sites More sharing options...
MasterACE14 Posted January 24, 2012 Share Posted January 24, 2012 what do you mean by 'it doesnt work' ? is there any errors coming up? Is it die()'ing somewhere in the script? Quote Link to comment https://forums.phpfreaks.com/topic/255653-php-send-email-script/#findComment-1310535 Share on other sites More sharing options...
gsencan Posted January 24, 2012 Author Share Posted January 24, 2012 when i enter aaa to first name and leave all fields blank it still gives the error ---->The First Name you entered does not appear to be valid. For example Quote Link to comment https://forums.phpfreaks.com/topic/255653-php-send-email-script/#findComment-1310537 Share on other sites More sharing options...
AyKay47 Posted January 24, 2012 Share Posted January 24, 2012 the pattern specified will work for aaa, have you echoed $_POST['first_name']; to make sure the value is what you expect? Quote Link to comment https://forums.phpfreaks.com/topic/255653-php-send-email-script/#findComment-1310611 Share on other sites More sharing options...
gsencan Posted January 24, 2012 Author Share Posted January 24, 2012 Yes missed that , it echo nothing. So that solves this problem but opens another 1 ... thx . Quote Link to comment https://forums.phpfreaks.com/topic/255653-php-send-email-script/#findComment-1310645 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.