SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Design and Promotion Crimson77's Avatar
    Join Date
    Aug 2006
    Location
    Australia
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Refreshing page on Submit

    Hi Guys,

    I'm greating a poll on one of my sites and I'm wondering if there is
    a way to make the page you're on refresh after the poll form is submitted.

    I can redirect to a specificed page on clicking the submit button but I want
    the page to redirect to what ever page it is presently on as if it is refreshing.

    I hope that makes sense.

    Look forward to any help you can give me.

    Thanks.

  2. #2
    SitePoint Addict -Ice-php's Avatar
    Join Date
    May 2002
    Location
    UK
    Posts
    260
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could put the forms action directing to the same file name? Or you could do it dynamically by using <?php echo $_SERVER['PHP_SELF']; ?> as the action.

    Is this what you mean?
    -Ice

  3. #3
    SitePoint Enthusiast baddot's Avatar
    Join Date
    Nov 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or you can post a if else stating which form to load with this variable detect with php self

    PHP Code:
    <form method="post" action="<?php echo "$PHP_SELF?filter=yes"?>">
    Make Friends And Earn Money @ Zonity.com
    Make Money at BadDot.com

  4. #4
    Design and Promotion Crimson77's Avatar
    Join Date
    Aug 2006
    Location
    Australia
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I need it to process the form then come back to the page the form was on, refreshing so that the poll updates. Will the methods you described be able to do this?

  5. #5
    SitePoint Member
    Join Date
    Mar 2006
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i'm not sure that i understand, try putting
    PHP Code:
    header('Location: first_page.php'); 
    on the end of second page..
    my little Blog

  6. #6
    Design and Promotion Crimson77's Avatar
    Join Date
    Aug 2006
    Location
    Australia
    Posts
    331
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I wanted was not to go back to the first page but to go to what ever page the poll was on when submitted.

    So let's say the poll appears on pages 1, 2 and 3.

    If I'm on page 1, I want the form to process then redirect me back to page 1.

    If I'm on page 2, I want the form to process then redirect me back to page 2.

    If I'm on page 3, I want the form to process then redirect me back to page 3.

    I don't want to have to right if statements for all of these options, so I was wondering if there is a function that will redirect to whatever page the form was submitted from. Whethere it's page 2 or page 102.

    Hope that makes a little more sense. I'm using the redirect to page1 at the moment but it's not ideal if the site gets out to too many pages.

  7. #7
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    pass the url to redirect to, as a query string param/hidden form field etc...

    validate it before you issue the redirect. or even better, just pass some type of id number which will internally map to the url.

    you may see it suggested to use $_SERVER['HTTP_REFERER'] but id avoid it if possible. its a user supplied value thats not reliable. its an optional value some browsers may send under the right conditons, and it can be spoofed.

  8. #8
    SitePoint Enthusiast baddot's Avatar
    Join Date
    Nov 2006
    Posts
    73
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u can use session to redirect the variables too
    Make Friends And Earn Money @ Zonity.com
    Make Money at BadDot.com

  9. #9
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    problem with using sessions for this is that once a user starts opening more than 1 window, your "navigation" breaks. a user using the backbutton in some circumstances could cause unexpected behavior as well, espescially when you start throwing potential caching into the mix.

    not to say you absolutely shouldnt use sessions for this, but these are some of the issues that need to be considered before you do.


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
  •