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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.