Grow your CSS skills. Land your dream job.

PHP + jQuery Contact Form – Recommendation

  • # September 22, 2009 at 1:12 pm

    Hello everyone,

    I am building a contact form as well as a registration form to be included in a WordPress template. So far the form is styled and the jQuery validation is working correctly. What I would like the form to do when it is submitted is do the back end validation, email the info to a set email address and then replace the form with a success message.

    Can anyone recommend a good tutorial? I have googled it but I seem to be swimming in a sea of contact forms.

    Thanks.

    # September 22, 2009 at 1:41 pm

    This one is pretty simple:

    http://scriptplayground.com/tutorials/p … -with-PHP/

    # September 22, 2009 at 2:39 pm

    Thanks for the link.

    I used the script and it passes on the info fine but I am wondering how I can go about displaying the success or failure message on the original contact page rather than having a new page loaded.

    User fills out info -> user clicks submit -> info is validated -> form disappears or fades out and is replaced by the success or failure message

    # September 22, 2009 at 3:20 pm

    Find this at the bottom:

    Code:
    if(mail($to, $subject, $message, $headers))
    {
    $result = “Thank you.
    I will get back to you very soon.
    “;
    }
    else
    {
    $result = “Sorry: An error occured, please try again later.”;
    }
    }

    And replace it with something like this:

    Code:
    $result = “../contact-success.php”;
    $errorpage = “../contact-error.php”;

    if(mail($to, $subject, $message, $headers))
    {
    header(“Location: ” . $result);
    }
    else
    {
    header(“Location: ” . $errorpage);
    }
    }

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".