Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/118680-login-problem/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-611121
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-611873
Share on other sites

<?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...

Link to comment
https://forums.phpfreaks.com/topic/118680-login-problem/#findComment-612204
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.