在php中使用大写和小写字符检查验证码

在php中使用大写和小写字符检查验证码,php,codeigniter,captcha,Php,Codeigniter,Captcha,我使用codeigniter,我想为captcha生成有效的数据,如果captcha混合了小写和大写字符,用户应该在输入中插入小写或大写或混合字符 在下面的代码中,我尝试了它,但它不检查小写和大写字符,如何修复它 我的验证码图像为:dAwVJ //$cap = $this->input->post('captcha'); $cap = 'dAwVJ';// if i change this to dawvj return(output) is true, i don't want t

我使用codeigniter,我想为captcha生成有效的数据,如果captcha混合了小写和大写字符,用户应该在输入中插入小写或大写或混合字符

在下面的代码中,我尝试了它,但它不检查小写和大写字符,如何修复它

我的验证码图像为: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;
}
尝试以下sql:

$sql   = "SELECT COUNT(*) AS count FROM captcha WHERE binary word = ? AND ip_address = ? AND captcha_time > ?";

你是说mysql中区分大小写的字符串比较?我想应该是这样的:
像binary这样的单词在哪里?


由于您使用的是codeigniter,这可能很有用:

我认为以区分大小写的方式检查验证码对每个用户都不友好,因为没有人能够识别随机验证码中的大写/小写差异,或者您的验证码很容易阅读(例如,所有字母大小相同),那么它仍然是无用的;)您是否检查过数据库排序规则不以_ci结尾,这意味着sql检查不区分大小写
$sql   = "SELECT COUNT(*) AS count FROM captcha WHERE BINARY word = ? AND ip_address = ? AND captcha_time > ?";