Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Resubmit POST form with just PHP

    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?

    Cheers,

    -- Ben Jones

  • #2
    New Coder
    Join Date
    Aug 2011
    Posts
    46
    Thanks
    9
    Thanked 2 Times in 2 Posts
    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.

  • Users who have thanked GreenFanta for this post:

    assassinator272 (11-13-2011)

  • #3
    Regular Coder primefalcon's Avatar
    Join Date
    Aug 2008
    Location
    /home/primefalcon/
    Posts
    678
    Thanks
    8
    Thanked 39 Times in 39 Posts
    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

    PHP Code:
    <?php

    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

  • #4
    New to the CF scene
    Join Date
    Nov 2011
    Posts
    6
    Thanks
    2
    Thanked 0 Times in 0 Posts

    [Issue Resolved]

    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
    Last edited by assassinator272; 11-13-2011 at 06:09 PM. Reason: Mark as resolved


  •  

    Posting Permissions

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