Adding Ajax to a Simple Formmail PHP page

Hi,

I am at the early stages of learning PHP and Ajax and would like detailed info on how I could update an existing Formmail form page to display a confirmation message on the same physical page without having to call a second 'ThankYou.html' type page.

When the user fills in the form and clicks submit, assuming the submission is successful, I would like to replace the actual form fields with a confirmation message. I'm assuming this requires Ajax.

Please provide details on how I can accomplish this.

Thank you!

jayschAsked:
Who is Participating?
 
mankowitzCommented:
0
 
maeltarCommented:
Just place the form in an if statement :

<?php
if (!(isset($_POST['Submit1']))) 
{

// code to display form

 }else{

// form processing code

// and thank you message

}
?>

html page footer

Open in new window

0
 
maeltarCommented:
That is an excellent example (just bookmarked it) however, with jaysch mentioning he is in the Early Stages I thought to show one of the many simple options...
0
 
Slick812Commented:
greetings  jaysch, , , If you are new to AJAX, I would highly recomend learning some of the basics of AJAX php, and doing some of your own AJAX pages, before you use a prepared javascript package like jquery or prototype or mootools. So you will know some about how AJAX works and try to understand it not in a javascript framework.

You might look at some of the many many AJAX tutorials on the web, here are a couple that are very basic -

http://www.w3schools.com/PHP/php_ajax_database.asp
http://www.ajaxf1.com/tutorial/ajax-php.html?page=2

I do not recomend these, they are very simple, but they may get you to see what it is that ajax does, and the begining methods for it's use, most AJAX code is more complex than these show.
ask questions if you need more info.
0
 
jayschAuthor Commented:
This example as exactly what I was looking for. Works great for what I need.

Thank you everyone for your input.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.