SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Once a page is redirected using header(), how to stop from going back to previous pag

    How do I keep a user from being able to go back to the previous web page once they have been redirected to another page?

    This is the general code that I am using to redirect them to the next page.

    PHP Code:
    <?php
     $thankYouPage 
    "thanks.php";
     
    header("Location: $thankYouPage");
    ?>
    <html>
    <body>
    </body>
    </html>
    Thanks

  2. #2
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    The simple answer is; you cant.

    The not so simple answer is; with You could use a permanent redirect to circumvent a moved page; but I get the impression that's not what you're after here.

    Why would you relocate someone immediately? Have you considered include instead of header'ing them forwards?
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  3. #3
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't understand completely what it is that you're saying because I don't think that I know enough yet, but what I'm trying to do is this:

    first page: have a form that is validated with jquery and php. The first page handles the jquery validation.

    second page: has the php validation on the second page and also the header redirect on the second page. The header redirect takes the user to a third page if all of the php validation is valid, otherwise it shows an error message telling the user what field input is missing, etc.

    third page: the thank you page. Once on this page, if the user presses the back page button on the web browser, they are taken back to the first page. I would like to be able to keep them from going back to the first page (with the form) in this way.

    Thanks

  4. #4
    Keeper of the SFL StarLion's Avatar
    Join Date
    Feb 2006
    Location
    Atlanta, GA, USA
    Posts
    3,748
    Mentioned
    69 Post(s)
    Tagged
    0 Thread(s)
    Well i'm not sure why you would want them not to go back to the form; you can try and subvert it by page 3 (i'd still recommend merging pages 2 and 3, but w/e) setting a $_SESSION variable to mark the form as having been filled out; have page 1 check for the variable, and if it exists, bounce the user to whereever you need them to go. Note that this means you will need to call session_start on the pages.

    You cannot manipulate the brower's history, because thats not in your security zone.
    Never grow up. The instant you do, you lose all ability to imagine great things, for fear of reality crashing in.

  5. #5
    SitePoint Member
    Join Date
    Jan 2013
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'll have to learn how use sessions with forms and I was just curious to see if and how to keep users from going back more than anything else.

    Thanks


Bookmarks

Posting Permissions

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