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!';
                }

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

Member Avatar

diafol

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.