hey_suburbia Posted August 10, 2006 Share Posted August 10, 2006 I have a very basic login that determines if the email address exists in the DB and if it does they get redirected, if not they get redirected elsewhere:[code]$fetch_exist=mysql_query("SELECT email FROM memberlist WHERE email = '$email'");//then check if the email is thereif(mysql_num_rows($fetch_exist)>0){ //it's in the database, bring them to logged in area header('Location: http://site.com/directory/page.php'); exit; }else{ //it's not in the database, bring them to sign-up header('Location: http://site.com/page2.html'); exit; }[/code]This works great.The problem occurs when I try to start the session, which is this:[code]session_start();$_SESSION ['email'] = $email;[/code]I tried putting it before the if/else statement, I tried putting it into the if statement. All return blank fields in the database.On my sign up page, I have the same thing (without the redirect and it works great).So, I guess my question becomes, where do I start the session on a page that redirects. I tried to start it on the page that you get redirected to, but I would have to pass the $email variable to that page...Any thoughts?THANKS!!! Quote Link to comment Share on other sites More sharing options...
pixy Posted August 10, 2006 Share Posted August 10, 2006 You have to put session_start(); before anything is sent to the browser. I've never had a problem setting the session and then redirecting whatsoever. Quote Link to comment Share on other sites More sharing options...
hey_suburbia Posted August 10, 2006 Author Share Posted August 10, 2006 thanks.So if I put the session_start() before this:[code]$fetch_exist=mysql_query("SELECT email FROM memberlist WHERE email = '$email'");//then check if the email is thereif(mysql_num_rows($fetch_exist)>0){ //it's in the database, bring them to logged in area header('Location: http://site.com/directory/page.php'); exit; }else{ //it's not in the database, bring them to sign-up header('Location: http://site.com/page2.html'); exit; }[/code]It should work, right? Quote Link to comment Share on other sites More sharing options...
Orio Posted August 10, 2006 Share Posted August 10, 2006 Yep :)Orio. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.