View Full Version : Resubmit POST form with just PHP

11-09-2011, 04:31 PM
Hi all,

First off, I have looked around the internet for a solution to this but nothing seems to match my needs exactly and I can't seem to modify any suggestions to work.

I am currently developing a room booking system for a client and several areas use POST forms.

Once a user has search for a room that's available, they can click a button to book it. When they do this, the details are submitted by POST to /book.php. However, in order to use this page, they also need to be logged in and so if they aren't they are redirected to /login.php.

When they then log in, I want a way of taking them back to /book.php (for ease of use, rather than having to perform the search all over again). This means that the details sent from the "search" form need to be resubmitted, otherwise /book.php will just redirect them back the homepage (because the page was accessed without using a POST form).

I have looked at cURL and the use of headers, but these seem to perform the POST in the background, whereas I want the user to follow the POST request to that page. I have also looked at using sessions, but this becomes quite messy with both POST and SESSION.

Can anyone think of or know of a way to solve this?


-- Ben Jones

11-09-2011, 05:27 PM
To be honest, on forms and such that require more than one page of data to be sent I've always just stuck to sessions.

11-10-2011, 08:41 AM
I agree just use php sessions, just chck if the session data is set and if so take that instead be just along the lines of


if(isset($_SESSION['whatever'])) {
//parse session data
} elseif (isset($_POST['whatever'])) {
//handle data from the form
} else {
//in this case there is no session data or form data so show form or whatever else you want

remember this is just an example and not working code

11-13-2011, 07:07 PM
Thanks for your help.

With a bit of moving of code and so on, I managed to get it working properly with sessions.

The login page is therefore not as dynamic as I'd like, but it's not a problem so I'm happy to live with it.

Thanks for the assist.

-- Ben Jones