runnerjp Posted May 20, 2007 Author Share Posted May 20, 2007 ahhh yes u man 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 } } /** * confirmUserID - Checks whether or not the given * username is in the database, if so it checks if the * given userid is the same userid in the database * for that user. If the user doesn't exist or if the * userids don't match up, it returns an error code * (1 or 2). On success it returns 0. */ function confirmUserID($username, $userid){ /* Add slashes if necessary (for query) */ if(!get_magic_quotes_gpc()) { $username = addslashes($username); } /* Verify that user is in database */ $q = "SELECT userid FROM ".TBL_USERS." WHERE username = '$username'"; $result = mysql_query($q, $this->connection); if(!$result || (mysql_numrows($result) < 1)){ return 1; //Indicates username failure } /* Retrieve userid from result, strip slashes */ $dbarray = mysql_fetch_array($result); $dbarray['userid'] = stripslashes($dbarray['userid']); $userid = stripslashes($userid); /* Validate that userid is correct */ if($userid == $dbarray['userid']){ return 0; //Success! Username and userid confirmed } else{ return 2; //Indicates userid invalid } } Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257426 Share on other sites More sharing options...
neel_basu Posted May 20, 2007 Share Posted May 20, 2007 Whats the Query for login. Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257429 Share on other sites More sharing options...
runnerjp Posted May 20, 2007 Author Share Posted May 20, 2007 function confirmUserPass($username, $password){ /* Add slashes if necessary (for query) */ if(!get_magic_quotes_gpc()) { $username = addslashes($username); } Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257435 Share on other sites More sharing options...
runnerjp Posted May 20, 2007 Author Share Posted May 20, 2007 /* 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 Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257440 Share on other sites More sharing options...
MadTechie Posted May 20, 2007 Share Posted May 20, 2007 $q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username' AND status = 1"; Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257471 Share on other sites More sharing options...
runnerjp Posted May 20, 2007 Author Share Posted May 20, 2007 sweet...how would i display an error if the users is 0 ?? Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257483 Share on other sites More sharing options...
MadTechie Posted May 20, 2007 Share Posted May 20, 2007 just update the failed login attempt, it would be easier Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257493 Share on other sites More sharing options...
runnerjp Posted May 20, 2007 Author Share Posted May 20, 2007 $q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username' AND status = 1"; didnt work as it still loggs u in if you are set to 0 Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257496 Share on other sites More sharing options...
MadTechie Posted May 20, 2007 Share Posted May 20, 2007 use $q = "SELECT password FROM ".TBL_USERS." WHERE username = '$username' AND status = '1'"; then.. if that failed then no idea.. i'm not very good at spaghetti code. Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257499 Share on other sites More sharing options...
runnerjp Posted May 20, 2007 Author Share Posted May 20, 2007 lol why u call it spaghetti code. Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257503 Share on other sites More sharing options...
runnerjp Posted May 20, 2007 Author Share Posted May 20, 2007 yes that worked....thank you so much Quote Link to comment https://forums.phpfreaks.com/topic/52025-solved-creating-random-numbers-and-adding-it-to-a-database/page/2/#findComment-257506 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.