princeofpersia Posted August 19, 2011 Share Posted August 19, 2011 Hi guys, I have a page where users can login, code below doesnt register sessions for my page I have session_start and ob_start on my db.php page and also added to this page but still can not get the session, I dont get any sytanx or include errors and everything is fine with database in terms of my registered email and password I would appreciate if you can see where I have made mistake, Thanks in advance <?php //ob ob_start(); //session session_start(); include ('../../include/db/connecttodb.php'); $session_email = $_SESSION['email']; ?> <!--Header starts here--> <?php include ('../../include/content/header.php'); include ('../../include/config/detect.php'); ?> <div id="breadcrumbs"><div id="text"><?php include($_SERVER['DOCUMENT_ROOT']."/backlinks.php"); ?></div></div><br/> <div id="pagetitleholder"><div id="pagetitle"> <h1>Login</h1></div></div> <!--Main body begins here--> <div id="maincontentbody"> <br /> <div id="logincontainer"> <div id="pagelogin"> <?php if(isset($session_email)) { echo"<a href='' class='minibutton'><span>Visit Your Profile</span></a>"; } else { if (isset($_POST['login'])) { $myemail=addslashes($_POST['email']); $mypass=addslashes($_POST['password']); if(!$myemail || !$mypass) echo"<div id='error'>Please enter both Email & Password</div><br/>"; else { $pass=md5($mypass); ///Check if account is active $mygets=sprintf('SELECT * FROM users WHERE myemail="%s" AND active="%s"', mysql_real_escape_string($myemail), mysql_real_escape_string($active)); $result = mysql_query($mygets); while($check_row=mysql_fetch_array($result)){ $myactive=$check_row['active']; } if ($myactive=0) echo "<div id='error'>Please activate your account before login</div><br/>"; else { $mylogin=sprintf('SELECT * FROM users WHERE myemail="%s" AND password="%s"', mysql_real_escape_string($myemail), mysql_real_escape_string($pass)); $resultlogin = mysql_query($mylogin); if(mysql_num_rows($resultlogin)>=1) { $_SESSION['email']=$email; //assign session //header("Location: ../profile/index.php"); //refresh echo"$email"; } else echo"<div id='error'>Your email is not registered with us!</div><br/>"; } } } echo"<div id='#logintitle'> <h2>Already Registered? Sign In Now</h2><br/></div> <div id='loginformbody'> <form name='login' action='' method='post'> <label for='email'>Email:</label><input type='text' name='email'/><br/> <label for='password'>Password:</label><input type='password' name='password' /><br/> <div id='logbtncon'> <input type='submit' name='login' class='logbtn' value='Log in'/> <a href='../recovery/'>Forgotton Password?</a> </div> </form> </div> "; }; ?> </div> <div id="notregistered"></div> </div> </div> <!--Main body ends here--> <!--Footer starts here--> <?php include ('../../include/content/footer.php') ?> <?php ob_flush(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/ Share on other sites More sharing options...
AyKay47 Posted August 19, 2011 Share Posted August 19, 2011 from the looks of it, an output buffer is not really needed here.. if you do a print_r($_SESSION); after you specify sessionstart(), what are your results..? Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/#findComment-1259425 Share on other sites More sharing options...
princeofpersia Posted August 19, 2011 Author Share Posted August 19, 2011 I get this Array ( => ) Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/#findComment-1259431 Share on other sites More sharing options...
Muddy_Funster Posted August 19, 2011 Share Posted August 19, 2011 where are you actualy populating your $_SESSION variables? Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/#findComment-1259439 Share on other sites More sharing options...
princeofpersia Posted August 19, 2011 Author Share Posted August 19, 2011 what do u mean? Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/#findComment-1259442 Share on other sites More sharing options...
Muddy_Funster Posted August 19, 2011 Share Posted August 19, 2011 I meen where are you defining the values for your $_SESSION variables. ie where are you telling the script what $_SESSION['email'] is to contain? Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/#findComment-1259446 Share on other sites More sharing options...
princeofpersia Posted August 19, 2011 Author Share Posted August 19, 2011 from post, in my form, i need to register this session from there, Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/#findComment-1259451 Share on other sites More sharing options...
Muddy_Funster Posted August 19, 2011 Share Posted August 19, 2011 but your POST is setting a value to $myemail, the SESSION is using $email Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/#findComment-1259452 Share on other sites More sharing options...
princeofpersia Posted August 19, 2011 Author Share Posted August 19, 2011 I get the point now, sorted thanks very much for your time mate Quote Link to comment https://forums.phpfreaks.com/topic/245204-session-register-issue/#findComment-1259459 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.