Anxious Posted April 19, 2009 Share Posted April 19, 2009 This code is within sesson.php <?php /* Checks that username is in database and password is correct */ $subuser1 = stripslashes($subuser1); $result = $database->confirmUserPass($subuser1, md5($subpass1)); /* Check error codes */ if($result == 1){ $field = "user1"; $form->setError($field, "* Username not found"); } else if($result == 2){ $field = "pass1"; $form->setError($field, "* Invalid password"); } else if($result = 3){ $field = "activate"; $form->setError($field, "* Account not activated"); } /* Return if form errors exist */ if($form->num_errors > 0){ return false; } ?> That checks the errors of course. That code goes to confirmuserpass, which is this. <?php function confirmUserPass($username, $password){ /* Add slashes if necessary (for query) */ if(!get_magic_quotes_gpc()) { $username = addslashes($username); } /* Verify that user is in database */ $q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username'"; $result = mysql_query($q, $this->connection); if(!$result || (mysql_numrows($result) < 1)){ return 1; //Indicates username failure } /* Retrieve password from result, strip slashes */ $dbarray = mysql_fetch_array($result); $dbarray['password'] = stripslashes($dbarray['password']); $password = stripslashes($password); /* Validate that password is correct */ if($password == $dbarray['password']){ return 0; //Success! Username and password confirmed } else{ return 2; //Indicates password failure } } ?> The error field is set for the the accounts that are not activated. Somewhere in that code, I'm guessing it should be written in confirmuserpass, is checking see if $activated ('activated' is the column in the database table) is set to 1. If it is, bring up the error field "account not activated" as set in sesson.php part (first code given). Else (set to 2) let the user login. What I thought origionally in session.php is this <?php if($activated = 1){ $field = "activate"; $form->setError($field, "* Account not activated"); } ?> This always brung up the field "Account not activated" even if it was. However, in confirmuserpass, if I added the following <?php if($activated = 1) { return 2; } ?> Would that work at all? If not, does anyone know what I need to do. Thanks. Link to comment https://forums.phpfreaks.com/topic/154762-solved-login-checking-user-is-activated/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.