在codeigniter问题中使用where子句

时间:2012-11-19 17:03:10

标签: php codeigniter

我在用户登录。因此,在用户委托电子邮件和密码后,我想检查是否存在具有该电子邮件和密码的用户。出于这个原因,我使用where子句两次但不知何故它不起作用。也许是因为我使用不正确。如何修复我的以下代码

$this->db->where('email', $this->input->post('email'));
$this->db->where('password', $pass . $salt);

1 个答案:

答案 0 :(得分:0)

哪里工作正常,这是第二个错误的地方,你传递密码+盐,但你没有编码任何东西,只是连接起来。因此,如果您的密码是bob而您的盐是胡椒,则您将bobpepper作为密码字段传递给查询。

根据加密情况,您的代码应与此类似:

 $password = md5($this->input->post('password'). $salt);  //swap the md5 for whatever encryption method you're using.
 $this->db->where('email', $this->input->post('email'));
 $this->db->where('password', $password);
相关问题