Detect previous page

Discussion in 'PHP' started by levani, Sep 1, 2009.

  1. #1
    I have one form on my site. Once the form is submited it's redirected to another php file (call it for example submit.php, this file executes data submission) and automatically returns back. This is a comments form and I would like to display thank you message after the form is submited so I need to detect somehow whether it comes from that php file or not. Is that possible using php?

    Thanks in advance
     
    levani, Sep 1, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can either check $_SERVER['HTTP_REFERER'] or you can use sessions and set a specific key once a message has been posted that you then check on the returning page to see if it exists. (and then unset it again)
     
    premiumscripts, Sep 1, 2009 IP
  3. levani

    levani Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your response! Unfortunately I have just started learning php and not so familiar yet. Could you tell me which method is better in this case and provide an example of code...

    Thanks
     
    levani, Sep 2, 2009 IP
  4. levani

    levani Peon

    Messages:
    61
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well I tried to echo the $_SERVER['HTTP_REFERER'] and it displays the same url not the submit.php. But I'm sure the form is redirected to this file!..
     
    levani, Sep 2, 2009 IP