简体   繁体   English

搜索表格以确认然后更新表格行

[英]Searching the table to confirm then updating a table row

hate to ask because I've been trying to do all of this on my own but it just will not work, i've searched everywhere and it says I'm doing it correctly不想问,因为我一直在尝试自己完成所有这些,但它不起作用,我到处搜索,它说我做对了

include "db.inc.php";

$ip = $_SERVER['REMOTE_ADDR'];
$ip = mysql_real_escape_string($ip);
$getcount = mysql_query("SELECT * FROM captcha WHERE ip='$ip'");
$resultc = mysql_result($getcount, 0, count);

if($resultc !== "5"){
    #header("Location: index.php");
    echo "don't work";
}else if($resultc == "5"){
    if (!isset($post)){
        $_SESSION['secure'] = substr(str_shuffle($charset), 0, 6);
    }else{
        if ($_SESSION['secure']==$post){
            mysql_query("UPDATE captcha SET count=0 WHERE ip='$ip'");
        }else{
            $error_message = "Incorrect, Try again";
            $_SESSION['secure'] = substr(str_shuffle($charset), 0, 6);
        }
    }
}

its searching the table for the matching ip, getting the number in count, if it does not = count it will echo "don't work" if it does it will do the captcha checks, everything in captcha check works except for the UPDATE它在表中搜索匹配的 ip,获取计数中的数字,如果它不是 = 计数它会回显“不工作”如果它会进行验证码检查,验证码检查中的所有内容都可以工作,除了更新

What i'm trying to do here is, I've made a custom Captcha which works, what i need to do now is when a users count is 5 which will add 1 to the current number everytime they successfully shrink a URL, I need it to check the db if it is not 5 I do not want them to have access to the captcha page so I need them to be redirected to the index page, if it is 5 it will go through the captcha which works, but I need to reset the count back to 0 after they enter the captcha code correctly, but it will not update the row.我在这里尝试做的是,我已经制作了一个有效的自定义验证码,我现在需要做的是当用户数为 5 时,每次他们成功缩小 URL 时都会将当前数字加 1,我需要它检查数据库是否不是 5 我不希望他们访问验证码页面,所以我需要将它们重定向到索引页面,如果是 5,它将通过有效的验证码,但我需要在他们正确输入验证码后将计数重置为 0,但不会更新该行。

@cody: you forgot quotes around "count". @cody:您忘记了“计数”周围的引号。
Replace:代替:

$resultc = mysql_result($getcount, 0, count);  

with:和:

$resultc = mysql_result($getcount, 0, 'count');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM