0

如果用户允许出现在页面中,我有一个名为“验证”的提交类型按钮。验证按钮将 db 中的一行设置为已验证 (TRUE)

如果验证字段为真或假,我首先在 db 中检查。

如果 false 和 isset($_POST['valid']) 我显示按钮

                        <input <?php echo $disabledvalid; ?> type="submit" class="sub" name="valid"  id="valid" value = "validate"   />

在我输入将验证字段从 FALSE 更改为 true 的 UPDATE 查询之后。

当页面被处理时,if 被忽略并被执行更新查询?

我该如何解决这个问题?

                <form action="view_support.php" method="post">
            <?php

            //check if validated field is true or false
            $queryvalid = "SELECT validated FROM support WHERE suppid = $suppid";
            $risqueryvalid = pg_query($queryvalid);
            $row = pg_fetch_array($risqueryvalid);
            $suppvalidated = $row['validated'];
            //echo "supp " . $suppvalidated;



            //$suppvalidated == "f";
            unset($_POST['valid']);
            //if validated field is false show me validate button
            if ( $suppvalidated == FALSE && (isset($_POST['valid'])  ){ 
                $suppvalidated = 'true';


                    <input <?php echo $disabledvalid; ?> type="submit" class="sub" name="valid"  id="valid" value = "validate"   />
                <?php

                if(isset($_POST['valid'])){
                    $vquery = "UPDATE support SET validated = $suppvalidated WHERE suppid = $suppid";
                    $risvquery = pg_query($vquery);
                    if (!$risvquery) {
                        #die("Error during insert support");    
                        die("Errore nella query $risvquery: " . pg_last_error());
                    }
                    unset($_POST['valid']);
                }
4

1 回答 1

0

编写此行时,您仍处于 PHP 模式:

<input <?php echo $disabledvalid; ?> type="submit" class="sub" name="valid"  id="valid" value = "validate"   />

你的右括号在哪里:

if ( $suppvalidated == FALSE && (isset($_POST['valid'])  ){ 
于 2012-10-16T20:55:35.407 回答