Davie33 Posted May 16, 2012 Share Posted May 16, 2012 Hi am in the middle of sorting this code but came across a problem that you may be able to help me with. As you can see this part of the code stops anyone from logging in if not activated there account but this seems to be doing it for those who have activated there account too if you need full code let me know plz thanks. if ($row['activated'] == 0) { echo 'Your email is not yet active. Please check your email!'; exit(); } Quote Link to comment https://forums.phpfreaks.com/topic/262624-help-with-loginphp-plz/ Share on other sites More sharing options...
scootstah Posted May 16, 2012 Share Posted May 16, 2012 Then obviously the "activated" column is not updating; so you need to look there first. Quote Link to comment https://forums.phpfreaks.com/topic/262624-help-with-loginphp-plz/#findComment-1345995 Share on other sites More sharing options...
Davie33 Posted May 16, 2012 Author Share Posted May 16, 2012 I have tryed a few things but none working. Here is my login code this may help abit more. <?php ob_start(); session_start(); include("includes/db_functions.inc.php"); include("includes/config.inc.php"); switch ($_GET['site']) { case 'facebook': include ($setting['sitepath']."/includes/social/login-facebook.php"); break; case 'twitter': include ($setting['sitepath']."/includes/social/login-twitter.php"); break; default: $username = yasDB_clean($_POST["username"]); $password = md5($_POST["password"]); $rememberme = $_POST["remember"]; $result = yasDB_select("select * from user where username='$username'",false); $rows = $result->fetch_array(MYSQLI_ASSOC); if (!$result || $result->num_rows == 0) { header("Location: index.php"); echo '<script type="text/javascript">alert("Wrong password and username combination.");</script>'; exit(); } $result->close(); if ($row['activated'] == 0) { yasDB_update("UPDATE * from user where username='$username'",true); echo 'Your email is not yet active. Please check your email!'; exit(); } if($rows['endban'] > time()) { $banend = date("F j, Y g:i a", $rows['endban']); echo 'Sorry, this user is banned until '.$banend; exit(); } if($rows['endban'] < time()) { yasDB_update("UPDATE user SET endban='0' WHERE username='$username'",false); } $loginok = ''; if($rows["password"]==$password && $rows["username"] == $username) { $loginok = TRUE; } else { $loginok = FALSE; } if ($loginok == TRUE){ $ref = $_SERVER['HTTP_REFERER']; if ($rememberme == "remember"){ setcookie("user", $username, time()+86400); // cookie lasts 24 hours } $_SESSION['user'] = $username; $_SESSION['userid'] = $rows['id']; $now = time(); $query = yasDB_select("SELECT `id` FROM `membersonline` WHERE `memberid` = '{$rows['id']}'"); if ($query->num_rows==0) { yasDB_insert("INSERT INTO `membersonline` (id, memberid, timeactive) VALUES ('', '{$rows['id']}', '$now')",false); } else { yasDB_update("UPDATE `membersonline` SET timeactive='$now' WHERE `memberid`='{$rows['id']}'"); } header ("Location: ".$setting['siteurl']); $query->close(); exit(); } else { echo '<script type="text/javascript" src="'.$setting['siteurl'].'includes/alert.js"></script>'; header ("Location: index.php"); exit(); } break; } ob_end_flush(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/262624-help-with-loginphp-plz/#findComment-1345996 Share on other sites More sharing options...
mrMarcus Posted May 16, 2012 Share Posted May 16, 2012 Show the code that runs when the user "activates" their account. Quote Link to comment https://forums.phpfreaks.com/topic/262624-help-with-loginphp-plz/#findComment-1345997 Share on other sites More sharing options...
Davie33 Posted May 16, 2012 Author Share Posted May 16, 2012 Hi every other part of the code works its just this file that doesn't which i know its missing something but dont know what.Without that activated code in login.php login works but.I need something in that file to stop the ones that have not activated there account Quote Link to comment https://forums.phpfreaks.com/topic/262624-help-with-loginphp-plz/#findComment-1345999 Share on other sites More sharing options...
mrMarcus Posted May 16, 2012 Share Posted May 16, 2012 if ($row['activated'] == 0) { should be: if ($rows['activated'] == 0) { Quote Link to comment https://forums.phpfreaks.com/topic/262624-help-with-loginphp-plz/#findComment-1346004 Share on other sites More sharing options...
Davie33 Posted May 16, 2012 Author Share Posted May 16, 2012 oops i did notice the s missing from row thank you so much for pointing that out its sorted the problem thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/262624-help-with-loginphp-plz/#findComment-1346007 Share on other sites More sharing options...
scootstah Posted May 16, 2012 Share Posted May 16, 2012 oops i did notice the s missing from row Then you need to turn on error reporting. ini_set('display_errors', 1); error_reporting(-1); Quote Link to comment https://forums.phpfreaks.com/topic/262624-help-with-loginphp-plz/#findComment-1346049 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.