Forums

Give help. Get help.

  • # 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 "name@something.com"















    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: http://jsfiddle.net/savver/KCpuR/

    You might wanna check your message before displaying 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.

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

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag