The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 2 of 2

Thread: Contact form - message sent confirmation

  1. #1

    Contact form - message sent confirmation

    Hi all,

    Is there a way to echo the "your message has been sent" on the same page of the contact form, (for example just under the form) instead of having it direct to another page? This is the code I have now.

    if ($name == "" || $email == "") {
    echo 'Please include your name and email. Thank you.';
    }
    else {
    $to = "email@example.com";
    $themessage .= "Name: $name\n\n Email $email\n\n Phone: $phone\n\n Comments: $comments";
    if (mail ($to,"website inquiry",$themessage, "From: $name <$email>")) {
    echo "Sent successfully!";
    //header ("location: mail_success.html?submit=true");
    } else {
    echo "There was a problem sending your message. Please go back and try again.";
    }
    }

    Thanks!

  2. #2
    You need something called AJAX to display the message without reloading the page. AJAX is basically a combination of JS and PHP (or any other server language). You would be using an AJAX POST request in your case. Learn how to do it here: http://www.w3schools.com/Ajax/Default.Asp .

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012