Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript jquery issues

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #39006
    cybershot
    Participant

    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.

     
    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);
    }

    }
    ?>





    Your message has been sent


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

    #106558
    Vermaas
    Participant

    Here, try this: http://jsfiddle.net/savver/KCpuR/

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

    #106564
    SgtLegend
    Member

    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)
  • The forum ‘JavaScript’ is closed to new topics and replies.