dq1230123 2014-09-12 00:32
浏览 19

PHP - 与我的验证码系统中的==相比,相同的文本字符串返回false

Ok, I've been struggling for days with this issue with my captcha system. First it always was returning false but if you refreshed the page it would log you in. Then I pinpointed where the error was occurring and simplified the code (removed the unneeded database queries and $_Sessions), and now I can't even sign in if I refresh the page after it returning false like before and the error appeared to be occurring here (before and currently):

if(strtolower($characters)==strtolower($_POST["security_code"])){

Even though the text from $characters and $_POST["security_code"] are the exact same, I always get it to return false. This is an example test.php I made to show it not working. I've tried doing stuff with sessions to fix this but I might of just not done it correctly and that's what needs to be done.

<?php
$possible = '23456789bcdfghjkmnpqrstvwxyz';
$characters = ''; 
$i = 0;

while($i < 8){
    $characters .= substr($possible, mt_rand(0, strlen($possible)-1), 1);
    $i++;
}

if(strtolower($characters)==strtolower($_POST["security_code"])){
    $captcha_solved = 'true';
}else{
    $captcha_solved = 'false';
}

?>
<form name="example" action="test.php" method="post">
     <input name="security_code" size="10" type="text">
     <input name="Login" value="Login" type="submit" value="submit">
</form>

<? echo($characters."-".$captcha_solved); ?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 C# TCP服务端,客户端退出后,不断有数据进来
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向
    • ¥15 如何用python向钉钉机器人发送可以放大的图片?
    • ¥15 matlab(相关搜索:紧聚焦)
    • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
    • ¥15 路易威登官网 里边的参数逆向
    • ¥15 Arduino无法同时连接多个hx711模块,如何解决?