monkeybidz Posted January 16, 2012 Share Posted January 16, 2012 I am having trouble calling the session var "email" from the landing page. Here is the code that I am using. I am not even sure the session "email" is starting or registering. $referer = $_SERVER['HTTP_REFERER']; $email = $_POST['email']; $sql="SELECT * FROM users WHERE email='$email' "; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $email, table row count must be 1 row if($count==1){ // Session Register email session_start(); $_SESSION['email'] = $email; header("location:".$referer2." "); exit(); } Link to comment https://forums.phpfreaks.com/topic/255150-php-session-help/ Share on other sites More sharing options...
DrTrans Posted January 16, 2012 Share Posted January 16, 2012 Would need to know if your post data $email = $_POST['email']; is working? have you tried to echo it out? if $email is not getting any post data then your session variable will be null. Link to comment https://forums.phpfreaks.com/topic/255150-php-session-help/#findComment-1308246 Share on other sites More sharing options...
AyKay47 Posted January 16, 2012 Share Posted January 16, 2012 I am having trouble calling the session var "email" from the landing page. Here is the code that I am using. I am not even sure the session "email" is starting or registering. $referer = $_SERVER['HTTP_REFERER']; $email = $_POST['email']; $sql="SELECT * FROM users WHERE email='$email' "; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); // If result matched $email, table row count must be 1 row if($count==1){ // Session Register email session_start(); $_SESSION['email'] = $email; header("location:".$referer2." "); exit(); } always have session_start() at the top of any page where you plan on using sessions, if session_start() is not there, sessions will not be displayed. Never have session start() in a condition. Link to comment https://forums.phpfreaks.com/topic/255150-php-session-help/#findComment-1308253 Share on other sites More sharing options...
monkeybidz Posted January 16, 2012 Author Share Posted January 16, 2012 Awsome! I was missing session_start(); on landing page. Thanks! Link to comment https://forums.phpfreaks.com/topic/255150-php-session-help/#findComment-1308288 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.