• # July 21, 2012 at 4:42 pm

    I have been going crazy for two hours trying to get this to work. I have a form, it works fine. After I submit the form, I want to display a success message and hide the form. Right now, after pushing the submit button, the form goes away, the success message displays for the blink of an eye and then the contact page shows normally. That is all fine, I just need the success message to stay up a bit longer.

     < ?php
    if (isset($_POST)) {

    $contactSubject = "";
    $from = "";
    $sendEmail = "";

    $contactName = strip_tags($_POST);
    $subject = strip_tags($_POST);
    $email = $_POST;
    $messages = strip_tags($_POST);
    //check to see if the variables are empty, if they are, just exit
    $validation = true;

    if (empty($contactName) || empty($email) || empty($messages)) {
    $validation = false;
    } else {
    $validation = true;

    if($validation == true){
    $contact = "Contact Name: $contactName n";
    $contact .= "Email: $email n";
    $contact .= "Subject: $subject n";
    $contact .= "Message: $messages n";

    $subject = $contactSubject;
    $headers = 'From: ' . $from . "rn" .
    'Reply-To: ' . $sendEmail . "rn" .
    'X-Mailer: PHP/' . phpversion();

    $recipient = $sendEmail;

    mail($recipient, $subject, $contact, $headers);


    • * Denotes Required Field

    • Proper format ""

    Your message has been sent

    The jqyery to run the success message is at the bottom of the code

    # July 21, 2012 at 8:00 pm

    Here, try this:

    You might wanna check your message before displaying the success message.

    # July 21, 2012 at 8:31 pm

    This reply has been reported for inappropriate content.

    It didn’t work. What is wrong with the success message?

    # July 21, 2012 at 10:03 pm

    Using jQuery to display a success message is a bad design as how does your client side code know if the email was sent successfully?

    What you need to be doing is using your PHP script to validate the data and check if the email got sent successfully and display a message based on the result.

    # July 21, 2012 at 10:24 pm

    This reply has been reported for inappropriate content.

    I am using the php to check that it got sent. then I am putting in some jquery to display the success message. I disagree with you that it is bad design as php works very well with html and javascript mixed. Also this is pretty much an accepted practice.

    # July 21, 2012 at 10:24 pm

    This reply has been reported for inappropriate content.

    I solved it this way


    Contact Form Submitted!

    .append("We will be in touch soon.")
    .fadeIn(10, function() {

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

You must be logged in to reply to this topic.