Jump to content


Photo

redirecting a web page along with session info


  • Please log in to reply
2 replies to this topic

#1 garry27

garry27
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 18 October 2006 - 02:37 AM

i have a self executable login script with a form that validates login credentials when you click the submit button.

what could i do to get it to redirect the user to another page as soon as it validates the user and carries the session variable on to the new script?



#2 HuggieBear

HuggieBear
  • Members
  • PipPipPip
  • Advanced Member
  • 1,899 posts
  • LocationEngland, UK

Posted 18 October 2006 - 03:00 AM

If the variable is set in the session then there's no need to do anything.

Redirect using the header() function.

<?php
if ($username == $validated){
   // if the user is validated then redirect using header
   header("Location: redirect.php");
}
?>

Assuming your user is saved in a session variable then you should be able to access like so...
echo $_SESSION['username'];
assuming that your variable is called username
Advice to MySQL users: Get phpMyAdmin and test your queries work there first, take half the hassle out of diagnosis, also check the reserved words list.

Links: PHP Docs :: RegEx's :: MySQL :: DevGuru :: w3schools

#3 garry27

garry27
  • Members
  • PipPipPip
  • Advanced Member
  • 161 posts

Posted 18 October 2006 - 03:05 AM

ok. thanks huggiebear.

;)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users