Jump to content

[SOLVED] Case sensitive


regdude

Recommended Posts

Hi!

I have made a login script.

It uses DB to get username and password.

But there is a problem with capital letters.

If I use, lets say, 'Username123' then I can get in the site behind login because this is in the DB, but if I use 'username123' I can also get in to the site.

(The script works for checking if password or username is correct).

$password = $_POST['password'];
$username = addslashes($_POST['username']);
$password = md5($password);
$result = mysql_db_query($db, "SELECT * FROM users WHERE username='$username' AND password='$password'"); 
if (mysql_num_rows($result) == 1) {
//... redirect.
}

Link to comment
https://forums.phpfreaks.com/topic/131689-solved-case-sensitive/
Share on other sites

Inserting?

<form  action='logingo' method='post' />
<center>
<table>
  <tr>
    <td>Username: </td>
    <td><input type='text' name='username' size='15' maxlength='20' /></td>
  </tr>
  <tr>
    <td>Password:</td>
    <td><input type='password' name='password' size='17' maxlength='30' /></td>
  </tr>
  
  <tr>
    <td></td>
    <td><input type='submit' value='Login' /></td>
  </tr>  
</table>

Wasn't really the solution he was looking for.  The problem is it isn't comparing case and he wants it to.

 

When you insert and compare the user names you should always use the strtolower or upper to ensure you don't run into this problem.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.