prova

If form was submitted validate it
If the form was submitted successfully
Send email(s)
Else
Set variables to show errors

If the form was submitted successfully
Show thank you message
Else
Show form (with errors if there are any)


Thanks,

Your email was successfully sent. I will be in touch soon.

There was an error submitting the form.

<form action="" id="contactForm" method="post">



< } ?>

  1. Name
    <input type="text" name="contactName" id="contactName" value="
    "
    class="requiredField" />


  2. Email
    <input type="text" name="email" id="email" value="
    "
    class="requiredField email" />


  3. Comments
    <br /><br /><br /><br /><br /><br /><br /><br />
    <?php if(isset($_POST['comments'])) {<br /><br /><br /><br /><br /><br /><br />
    if(function_exists('stripslashes')) {<br /><br /><br /><br /><br /><br /><br />
    echo stripslashes($_POST['comments']);<br /><br /><br /><br /><br /><br /><br />
    } else {<br /><br /><br /><br /><br /><br /><br />
    echo $_POST['comments'];<br /><br /><br /><br /><br /><br /><br />
    }<br /><br /><br /><br /><br /><br /><br />
    } ?>


  4. <input type="checkbox" name="sendCopy" id="sendCopy" value="true"
    />
    Send a copy of this email to yourself
  5. If you want to submit this form, do not enter anything in this field
    <input type="text" name="checking" id="checking" class="screenReader" value="
    "
    />
  6. Email me »

  • If you want to submit this form, do not enter anything in this field
    <input type="text" name="checking" id="checking" class="screenReader" value="">
  • .screenReader {
    left: -9999px;
    position: absolute;
    top: -9999px;
    }


    //Check to see if the honeypot captcha field was filled in
    if(trim($_POST['checking']) !== '') {
    $captchaError = true;
    } else {

    }

    //Check to make sure that the name field is not empty
    if(trim($_POST['contactName']) === '') {
    $nameError = 'You forgot to enter your name.';
    $hasError = true;
    } else {
    $name = trim($_POST['contactName']);
    }

    //Check to make sure sure that a valid email address is submitted
    if(trim($_POST['email']) === '') {
    $emailError = 'You forgot to enter your email address.';
    $hasError = true;
    } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+.[A-Z]{2,4}$", trim($_POST['email']))) {
    $emailError = 'You entered an invalid email address.';
    $hasError = true;
    } else {
    $email = trim($_POST['email']);
    }

    //Check to make sure comments were entered
    if(trim($_POST['comments']) === '') {
    $commentError = 'You forgot to enter your comments.';
    $hasError = true;
    } else {
    if(function_exists('stripslashes')) {
    $comments = stripslashes(trim($_POST['comments']));
    } else {
    $comments = trim($_POST['comments']);
    }
    }:

    if(trim($_POST['contactName']) === '') {
    $nameError = 'You forgot to enter your name.';
    $hasError = true;
    } else {
    $name = trim($_POST['contactName']);
    }

    //If there is no error, send the email
    if(!isset($hasError)) {

    $emailTo = 'me@somedomain.com';
    $subject = 'Contact Form Submission from '.$name;
    $sendCopy = trim($_POST['sendCopy']);
    $body = "Name: $name nnEmail: $email nnComments: $comments";
    $headers = 'From: My Site <'.$emailTo.'>' . "rn" . 'Reply-To: ' . $email;

    mail($emailTo, $subject, $body, $headers);

    if($sendCopy == true) {
    $subject = 'You emailed Your Name';
    $headers = 'From: Your Name <noreply@somedomain.com>';
    mail($email, $subject, $body, $headers);
    }

    $emailSent = true;

    }

    %d blogger hanno fatto clic su Mi Piace per questo: