dnbhead22 Posted April 2, 2012 Share Posted April 2, 2012 errors: Deprecated: Function session_register() is deprecated in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 18 Warning: session_register() [function.session-register]: Cannot send session cookie - headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/login.php:18) in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 18 Warning: session_register() [function.session-register]: Cannot send session cache limiter - headers already sent (output started at /Applications/XAMPP/xamppfiles/htdocs/login.php:18) in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 18 Deprecated: Function session_register() is deprecated in /Applications/XAMPP/xamppfiles/htdocs/login.php on line 22 Code: <?php if ($_POST['email']) { include_once "connect_to_mysql.php"; $email = stripslashes($_POST['email']); $email = strip_tags($email); $email = mysql_real_escape_string($email); $password = preg_replace("[^A-Za-z0-9]", "", $_POST['password']); $password = md5($password); $sql = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$password' AND emailactivated='1'"); $login_check = mysql_num_rows($sql); if($login_check > 0){ while($row = mysql_fetch_array($sql)){ $id = $row["id"]; session_register('id'); $_SESSION['id'] = $id; $username = $row["username"]; session_register('username'); $_SESSION['username'] = $username; mysql_query("UPDATE members SET lastlogin=now() WHERE id='$id'"); header("location: member_profile.php?id=$id"); exit(); } } else { print '<br /><br /><font color="#FF0000">No match in our records, try again </font><br /> <br /><a href="login.php">Click here</a> to go back to the login page.'; exit(); } } ?> any help really appreciated...thanks!! Quote Link to comment https://forums.phpfreaks.com/topic/260194-login-trouble/ Share on other sites More sharing options...
Muddy_Funster Posted April 2, 2012 Share Posted April 2, 2012 comment out the two lines that have "session_register(xxx)" on them, and add "session_start()" to the page directly under the opeing php tags. the problem with the header is that it can't perform the action because the warnings are being thrown by the depreciated function and as such there is information being passed to the screen before the header call - which just doesn't work. Quote Link to comment https://forums.phpfreaks.com/topic/260194-login-trouble/#findComment-1333580 Share on other sites More sharing options...
dnbhead22 Posted April 2, 2012 Author Share Posted April 2, 2012 perfect. thanks alot Quote Link to comment https://forums.phpfreaks.com/topic/260194-login-trouble/#findComment-1333584 Share on other sites More sharing options...
dnbhead22 Posted April 2, 2012 Author Share Posted April 2, 2012 it works fine when im logged in on the members page but when i return to the home page the login function resets and it doesnt keep me logged in. Quote Link to comment https://forums.phpfreaks.com/topic/260194-login-trouble/#findComment-1333636 Share on other sites More sharing options...
Muddy_Funster Posted April 2, 2012 Share Posted April 2, 2012 you will need to put the session_start() code at the top of every page you have that will be visited within the session, otherwise the session will be droped. Quote Link to comment https://forums.phpfreaks.com/topic/260194-login-trouble/#findComment-1333704 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.