login then back to the previous page

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mcmall
    New Member
    • Nov 2008
    • 3

    login then back to the previous page

    Hi I am a newbie, and I am having some troubles need someone to help me out. I am currently having a login page.

    heres my login form
    Code:
    <form action="member.php?action=logindo" method="post" id="form_login" name="form_login" >
    <input type="text" name="txtloginname" id="txtloginname" tabindex="1"/>
    <input type="text" name="txtloginpwd" id="txtloginpwd" tabindex="1"/>
    <input name="save" id="save" value="submit">
    </form>
    How do I write a php page so that if someone login then the page will back to the previous page automatically. (LIKE EBAY)

    should I use <input="hidde n" or ['_SERVER']['HTTP_REFERER']??
    Last edited by Markus; Nov 2 '08, 08:08 PM. Reason: added # tags
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Have a hidden input on your form that stores the url of the page the form is on (relative or full). Then use the header() function to redirect to the page.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      You could also just use the $_SERVER['HTTP_REFERER'] variable in your "member.php " page.

      For example:
      [code=php]
      <?php
      // Do your login stuff here...

      header("Locatio n: ". $_SERVER['HTTP_REFERER']);
      ?>
      [/code]
      Note that the HTTP_REFERER is supplied by the client, so this might be used to feed bad URL's in to the redirect. (Although I fail to see how this might be abused for malicious purposes. (but then again, I am not thinking at 100% capacity at the moment :P))

      Comment

      • mcmall
        New Member
        • Nov 2008
        • 3

        #4
        Thanks alot guys!!!!

        Comment

        Working...