0

this code doesnt check captol letters. how can i do this.
for examle is i have "cat" in table "user". than if i set $username_p to Cat. and it will work fine.
but i dont want to work bc Cat != cat.

$sql = mysql_query("SELECT id FROM user WHERE username='$username_p' AND password='$password_p' LIMIT 1");

full code....

    $sql = mysql_query("SELECT id FROM user WHERE username='$username_p' AND password='$password_p' LIMIT 1");

                //make sure person exists in database---
                $existCount = mysql_num_rows($sql); //count the row num
                if($existCount == 1) //make sure name is only one in database
                {
                    while($row = mysql_fetch_array($sql))
                    {
                        $id = $row["id"];
                    }
                    //create session variables
                    //so site can remember who loged in
                    $_SESSION["id"] = $id;
                    $_SESSION["username"] = $username_p;
                    header("location: index.php");  
                }
                else
                {
                    $log_error .= 'Error - Incorrect username or password!';
                }
3
Contributors
4
Replies
5
Views
4 Years
Discussion Span
Last Post by hwoarang69
1

You'll need to change your collation to something that is case sensitive. Case insensitive is usually default.

2

Use the BINARY key word:

"SELECT id FROM user WHERE BINARY username='$username_p' AND password='$password_p' LIMIT 1"

I'm assuming the password is hashed so you don't need this case sensitivity on that.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.