Jump to content


Photo

help with redirection


  • Please log in to reply
2 replies to this topic

#1 icon

icon
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 12 April 2006 - 06:20 PM

hi


i have made a site which uses mysql with sessions, but what i wont to know is i have the following code:

<?

if(!$_SESSION['username']){

header("Location: [a href=\"http://domain");\" target=\"_blank\"]http://domain");[/a]

} else {

print <<<END

html

END;
}
?>



on the page to protect and if there is no session name in the current session it redirect to the login page how do i have a query string added to the url that send it back to the page it come from like ie domain.com/bahbah/?url=http://home.domain.com

thanks

#2 jworisek

jworisek
  • Members
  • PipPipPip
  • Advanced Member
  • 112 posts

Posted 12 April 2006 - 07:31 PM

what you say is exactly right...

just add

?url=http://www....whatever

or you could even just use php server variable to get the referring page.

I like to add an error variable on to saty something like
$error_explain="Your Session has timed out.  Please log back in.";

header("Location: http://domain/login.php?url=http://referrer&amp;error=$error_explain");


#3 icon

icon
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 12 April 2006 - 10:16 PM

i have added url=http://referrer&amp on the end of the url but it doesnt work, is there a variable that calls what page it come from




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users