0

I am learning out to do website log-in and create creation. I am facing the probably where my script does not check if the two strings are the same case. Example, Foo and foO return both true.

My current PHP script is:

//Create query
$qry="SELECT * FROM member WHERE username='$username' AND password='$password'";
$result=mysql_query($qry);

//Check whether the query was successful or not
if($result) {
    if(mysql_num_rows($result) > 0) {
        //Login Successful
        session_regenerate_id();
        $member = mysql_fetch_assoc($result);
        $_SESSION['SESS_MEMBER_ID'] = $member['mem_id'];
        $_SESSION['SESS_FIRST_NAME'] = $member['username'];
        $_SESSION['SESS_LAST_NAME'] = $member['password'];
        session_write_close();
Rguarascia
  • 133
  • 1
  • 17

3 Answers3

0

you can use "COLLATE latin1_general_cs" character set to differentiate to upper case or lower case.

SELECT * FROM `table` WHERE `your condiction` COLLATE latin1_general_cs;

or you can use

SELECT *  FROM `table` WHERE BINARY `column` = 'value'
Vaibhav Singhal
  • 502
  • 1
  • 3
  • 21
0

If you are in the WINDOWS: you can find the my.ini and change the lower_case_table_names=0. If you are in the LINUX: you can find the my.cnf and change the lower_case_table_names=0.

danny sun
  • 11
  • 1
0

The default collation for character set latin1, which is latin1_swedish_ci, happens to be case-insensitive.

You can choose a case-sensitive collation, for example latin1_general_cs while creating a database schema . Have look in this link

https://dba.stackexchange.com/questions/15250/how-to-do-a-case-sensitive-search-in-where-clause

Community
  • 1
  • 1
Avijit Das
  • 290
  • 1
  • 5
  • 20