0

my code

// My code:

$this->db->select('*')
->from('tbl_login')
->where(['username'=>$this->input->post('username'),'password'=>$this->input->post('password')]);
$result = $this->db->get()->result();

if($result)
    var_dump($result)
else
    echo "not fount";

Doesn't matter what ever I input 'admin1' or 'ADMIN1' & 'password1' or 'PASSWORD1' it retrieves data from the tables. But what I actually want is data will be retrieve when case is matched correctly.

Could anyone help???...

Tpojka
  • 6,996
  • 2
  • 29
  • 39
Amin
  • 681
  • 4
  • 9
  • 27
  • Your database columns are probably defined with case-insensitive collations. Change their collations to case-sensitive and you should be fine. – eggyal Aug 14 '16 at 09:35
  • 1
    **WARNING**: Do not write your own user authentication system, as there are many, many ways to get it dangerously wrong. Using **plain-text passwords** is one such failing. [Codeigniter has many packages](http://stackoverflow.com/questions/33311725/codeigniter-3-x-authentication-library) which already work. I'd strongly encourage you to find one that fits your needs, or which is close enough you can adapt it to suit what you're doing. – tadman Aug 14 '16 at 09:46

1 Answers1

0

Try this one

  $query = $this->db->select("*")->from("tbl_login")->where("BINARY username= '".$this->input->post('username')."' and password = '".$this->input->post('password')."'");

  $result = $this->db->get()->result();

   if($result)
      var_dump($result)
   else
      echo "not found";

Note: Basically use BINARY before your where conditions in Query.

Hope this will help!!