我使用codeigniter,我想为验证码制作有效数据,如果验证码混合了大写和小写字符,用户应该在输入中插入大写或大写或混合它们。
在下面的代码中我试了一下,但它没有检查大小写的字符,如何修复呢?
我的验证码图片如下: dAwVJ
//$cap = $this->input->post('captcha');
$cap = 'dAwVJ';// if i change this to dawvj return(output) is true, i don't want this
// Then see if a captcha exists:
$sql = "SELECT COUNT(*) AS count FROM captcha WHERE word = ? AND ip_address = ? AND captcha_time > ?";
$binds = array(
$cap,
$this->input->ip_address(),
$expiration
);
$query = $this->db->query($sql, $binds);
$row = $query->row();
if ($row->count == 0) {
return false;
} else {
return true;
}
答案 0 :(得分:1)
试试这个sql:
$sql = "SELECT COUNT(*) AS count FROM captcha WHERE binary word = ? AND ip_address = ? AND captcha_time > ?";
答案 1 :(得分:1)
你的意思是mysql中的区分大小写的字符串比较?我认为会是这样的:WHERE word like binary ?
由于您使用的是codeigniter,这可能很有用:mysql, case sensitive compare through codeigniter
答案 2 :(得分:0)
$sql = "SELECT COUNT(*) AS count FROM captcha WHERE BINARY word = ? AND ip_address = ? AND captcha_time > ?";