ballouta Posted August 7, 2008 Share Posted August 7, 2008 Hi I have a login page, i never thought that if the user writes his username in big letters instead of small letters, the code accepts it. while this user has registered before will small letters username! I used the lowercase function inorder to make all logins small letters but it is not nice and it is for temp. use. What if a user wants to choose a user name like this: BaLLoutA? Please Help Thank You Quote Link to comment https://forums.phpfreaks.com/topic/118680-login-problem/ Share on other sites More sharing options...
discomatt Posted August 7, 2008 Share Posted August 7, 2008 I'm assuming you're using a database to store users. Use SELECT `info` FROM `users` WHERE `username` = '$username' rather than SELECT `info` FROM `users` WHERE `username` LIKE '$username' 'LIKE' is case-insensitive, while '=' isn't. Quote Link to comment https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-611121 Share on other sites More sharing options...
ballouta Posted August 8, 2008 Author Share Posted August 8, 2008 Hi this is the query I am using: <?php $query = "SELECT * FROM `members` WHERE `user` = '$user' and `pass` = '$pass' "; ?> when the user writes his username when caps lock is on, the code lets the user to go to his control panel, but when the user does some process, he gets errors because the code doesn't find his own folder which is originally created in small letters as he first registered. What I prefer is that the user logs in excatly with the user name he chose when creating his account. e.g.: BalloutA I noticed that the registration code inserts the username as is (e.g. BalloutA), here we don't have any problem. but the problem (as I said) when the user logs in and does some processes. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-611873 Share on other sites More sharing options...
ballouta Posted August 9, 2008 Author Share Posted August 9, 2008 any solution please Quote Link to comment https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-612194 Share on other sites More sharing options...
Andy-H Posted August 9, 2008 Share Posted August 9, 2008 if ( strtolower($variable1) != strtolower($variable2) ){ echo "Error message."; }else{ blah; } Quote Link to comment https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-612197 Share on other sites More sharing options...
Andy-H Posted August 9, 2008 Share Posted August 9, 2008 Also you should fetch the data from the database and start a session with the fetched data rather than starting the session with the user input. Quote Link to comment https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-612198 Share on other sites More sharing options...
Andy-H Posted August 9, 2008 Share Posted August 9, 2008 <?php if ( !empty($_SESSION['username']) ){ Header("Location: blah.php"); } $query = "SELECT user FROM members WHERE user = '$user' and pass = '$pass' LIMIT 1"; $result = mysql_query($query)or die(mysql_error()); $num = mysql_numrows($result); if ($num == 0){ echo "Incorrect username/password combination"; }else{ $row = mysql_fetch_row($result); $username = $row[0]; $_SESSION['username'] = $username; Header("Location: blah.php"); } ?> Like that... Quote Link to comment https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-612204 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.