Checking username(upper and lower)

Started on the old forum in June 2012 · view the original in the archive · old links redirect here

14 replies · 1,019 views · started 14 years ago · 1 min read

10 participants
analyzer Developer · 104 posts #1

I was trying to check username in my login form that when someone puts username which is not exactly the same with the registered username, he/she will fail to login. Example. . Registered username is tEst and password is test, when someone tried to log in using "test" as username it will not log in because letter "e" must be "E". So it should be "tEst". How will i'am going to verify that?

It's n0t that i am afraid to die. Its just that if i die, wh0 wilL loVe her as muCh as i Do?

ionutvmi Junior · 45 posts #2

check with phpmyadmin if the Collation of your username column is latin1_swedish_ci alternatively you could use strtolower() on your login page

PIMP-WAP.NET - PIMP YOUR MOBILE

MASTER-LAND.NET - WAPMASTERS LAND

analyzer Developer · 104 posts #3

The collation is latin1_swedish_ci but still doesn't work. I check it in my sql using, WHERE username='".$username."'

It's n0t that i am afraid to die. Its just that if i die, wh0 wilL loVe her as muCh as i Do?

analyzer Developer · 104 posts #5

I'll try it bro, thanks!

It's n0t that i am afraid to die. Its just that if i die, wh0 wilL loVe her as muCh as i Do?

arevel Newbie · 4 posts #7

try strtolower($username);

Ghost Senior · 366 posts #8

arevel wrote: try strtolower($username);

this makes all characters lowercase. but the original poster wants to check for case "insensitive" characters. so the user is able to use both upper and lower case at same time.

<?php include ('Ghost'); if ($Post == true) { echo ' ![](http://destrukt.dk/ico/phpdeveloper.jpg) alt='coding-talk.com!!' />'; echo 'Sharing Is Caring!'; } else { echo ' ![](http://img98.imageshack.us/img98/6476/av3ro4.jpg) alt='the username GHOST has been comprimised!' />'; echo 'OMG SOMEBODY HELP ME!!'; } ?>
$XTREME$ Developer · 82 posts #9

$xtreme = strtolower ( $username );

and get ur sql output with strtolower , then it ll be ,k . Hmm

Vayne Developer · 106 posts #10

GumSlone wrote:

WHERE username LIKE '{$username}'

thats a nice server killer. and what if there`s about 1kk users + every second one of them (or more) tries to login?

Nous Ne Dansos Pas, Nous Sommes Le Danse.!

nimeshka Developer · 180 posts #11

Hai bro, there is a function in PHP to compare the case of two strings..use strcmp();

$str1 = "TesT";
$str2 = "Test";

$true = strcmp($str1,$str2);

if($true==0){
echo "Two strings are identical";

} else {

echo "Two strings are not identical";

}

Note : strcmp(); returns 0 if the two are identical in case. if not it will return greater than or less than 0 depending on the condition

hope this will solve your problem.

External image (may be gone)

I'm Proud to be a Sri Lankan!

arnage Lead · 811 posts #13

nimeshka wrote: Hai bro, there is a function in PHP to compare the case of two strings..use strcmp();

$str1 = "TesT";
$str2 = "Test";

$true = strcmp($str1,$str2);

if($true==0){
echo "Two strings are identical";

} else {

echo "Two strings are not identical";

}

Note : strcmp(); returns 0 if the two are identical in case. if not it will return greater than or less than 0 depending on the condition

hope this will solve your problem.

strcmp() is case sensitive, strcasecmp() is case insensitive. 🙂

<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***
arnage Lead · 811 posts #15

Yep, i didn't read it right, i thought that he wants vice versa.

Here is another way.

$query = mysql_query('SELECT * FROM `users` WHERE MATCH(users) AGAINST("'.$login.'" IN BOOLEAN MODE)');
<!DOCTYPE html PUBLIC "-//***WAPFORUM**.**RS***

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close