May 7, 2013

PHP – Avoid reloading page after form submit

User2108393’s Questions:

I’m new to php and web-programming… I’m working on a school project modifying databases through a corporate site.

I’m using some forms to allow the user to look for information that will be used to fill up other forms on the same page. In this case, a car rental, I look for available cars, show them on a table and then the user picks a car and its info would fill up some other inputs on the same page.

I’m able to do the search and show the result, but then when the user picks the car and clicks submit the whole page is uploaded again. Please, any suggestions?

J.

Redirect to a different page/route, other than the one page was submitted to.

An example for different page redirection.

header("location: differentpage.php");
exit;

Once you are in differentpage.php you cannot reload the POST request. TO get the data you can use SESSION or GET parameter as per requirements.

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!