Login Script Redirection issues

danielneridanielneri WP V.I.P.VPS - Virtual Prince of the Server
alright so i have this login script that logs in the user perfectly fine, but then it redirects back to the index page on dafault. how do i make it so the header location redirects back to the page it came from?

thanks
ban1.gif

Comments

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    anyone?
    ban1.gif
  • PythonPython Forum Leader The Royal RAM
    You would have to have some sort of hidden tag in the form which contains the name of the page the user is currently on. And then when they login the script directs them back to that page...

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    example???
    ban1.gif
  • PythonPython Forum Leader The Royal RAM
    [HTML]<input type="hidden" name="goto" value="news">[/HTML]

    Have that bit of code within the form tags of the login form...

    Then in the actual login.php script or whatever is doing the login processing just then make it redirect to the value of that hidden input...

    For example in PHP you could access that value using $_POST[goto]

    Maybe echo that out in a link, put .html after it and it would link the user back.. Or you could make it automatically redirect...

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    but using that script ^^ i would have to manually code each page by myself...isnt there som way i could do something like
    [php]header("Location: [referring page???]");[/php]

    anything?
    ban1.gif
  • PythonPython Forum Leader The Royal RAM
    you could use $_PHPSELF

    I think thats right anyway... basically that preset variable contains the current filename/location of the user...

    The Royal Ram

  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    but wouldnt that make it redirect to the login.php itself? i mean if i put phpself on the login page as a redirect.....

    im trying to say is there any way i can make the script redirect to the page it CAME from automatically??
    ban1.gif
  • FelixFelix Junior Member Shared Hoster
    Yes there is. After user has successfully logged in you need to do:

    [PHP]
    header("location: " . $_SERVER);
    [/PHP]

    :D
  • danielneridanielneri WP V.I.P. VPS - Virtual Prince of the Server
    thank you so much felix
    ban1.gif
Sign In or Register to comment.