0

I need to consider case sensitivity when login to my system. But password do not consider case.

    $this->db->select('user.*,userprofile.*,user.id as uid');
    $this->db->from('user');
    $this->db->join('userprofile', 'userprofile.id = user.id');
    $this->db->like('email', $udata['email']);
    $this->db->like('password', $udata["password"]);
    $query = $this->db->get();

The above is my query. How can I change it so that its case sensitive?

shavindip
  • 607
  • 9
  • 27
  • 2
    You shouldn't need to do anything with the password field to make it case sensitive unless you are storing passwords in plain text, which you __really__ should not be doing! By using a hash function, the input you provide will provide a hash which will be completely different if the case is incorrect. – gabe3886 Aug 31 '18 at 07:58
  • Thanks a lot this helped – shavindip Aug 31 '18 at 08:07

2 Answers2

1

a possible approach could be

$this->db
    ->select('user.*,userprofile.*,user.id as uid')
    ->from('user')
    ->join('userprofile', 'userprofile.id = user.id')
    ->where('email', $udata['email'])
    ->where('BINARY password =', $this->db->escape($udata["password"]), false)
    ->get();

For more information take a look here

Atural
  • 5,389
  • 5
  • 18
  • 35
1

I changes my variables names to get the two separately and used LIKE inside 'where'.

I changes this :

$this->db->like('password', $udata["password"]);

to

$this->db->where('password LIKE binary', $password);
shavindip
  • 607
  • 9
  • 27