After submitting the php form I want to display the message in the same page

Hi all

I have one php form which is taking the booking details, when submit button is clicked it is going to another php form to execute the sql query to insert the data into database.

After submitting the data into database i want to display the message in the same page. how to do it any, any help is appreciated



After submitting the form to the processing page, use

* do processing and error checking

header("Location: originalPageWhereTheFormIs.php?formsubmit=1"); 

and on the original page that has the form, check for the formsubmit variable you just sent back

if(isset($_GET['formsubmit'])) {

// if the form has been submitted
echo 'Thank you';

} else {

// show the form


see for information on using header()

Hello samiuddin,

Why dont u try “ajax”. If you try ajax then the whole page wont get loaded. The value which is entered also will be there. If u want to reload the page then the header location is fine. Other wise u just try ajax. Then u may find out the differences.

For example, if u want to display any error msgs then the old value will be persist at the same time u can show ur error msgs as well.

If u use ajax and u want to load the whole page, then u use javascript’s window.location.href.


I wouldn’t recommend using ajax because you then have to use another method anyway to submit the booking from javascript disabled browsers.

The technique that’s easiest to code and provides the most stable result is to ensure that the page works entirely without any javascript coding.

Then, once the page is in a working state, can you enhance things with javascript. That ensures that the page can still work correctly should client-side scripting not be available.

yep that’s another option. The previous poster didn’t mention the potential pitfall in using javascript/ajax and so I just wanted to make sure the pitfall was out there.