Jump to content

php send email script


gsencan

Recommended Posts

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);

Link to comment
https://forums.phpfreaks.com/topic/255653-php-send-email-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.