Welcome Guest, Not a member yet? Register   Sign In
case sensitive querying
#1

[eluser]tastebuds[/eluser]
Hi good day folks! Please bare with my noobish question i just cant get any answer
but here's my problem. I made a simple login system but i want it to be a case sensitive, i dont know if the sql is wrong or something here is the snippet of my model


Code:
function verify($username=NULL, $password=NULL){
  
  $sql = "SELECT * FROM admin WHERE username = ? AND password = ?";
  $query = $this->db->query($sql, array($username, $password));
  
  if($query->num_rows>0){
   $user = array(
      'username' => $username,
      'password' => $password,
      'is_logged_in' => TRUE
     );
   $this->user_info = $this->session->set_userdata($user);
  
   return TRUE;
  }else{
  
   return FALSE;
  }
}


by the way i am using wamp and i already tried to changed the collation of my table to latin1_bin and latin1_general_cs. Sorry again for this question..
I really appreciate for any response
Thank you ^_^

#2

[eluser]InsiteFX[/eluser]
It has nothing to do with your database its how you convert your string before adding them.
Code:
// all uppercase
   $user = array(
      'username' => strtoupper($username),
      'password' => strtoupper($password),
      'is_logged_in' => TRUE
     );

// all lowercase
   $user = array(
      'username' => strtolower($username),
      'password' => strtolower($password),
      'is_logged_in' => TRUE
     );




Theme © iAndrew 2016 - Forum software by © MyBB