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

Link to comment
Share on other sites

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.

Link to comment
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.