0

I have a submit type button called "validate" if user has allowed appeared in page. validate button set a row in db as validated (TRUE)

i check first in db if validated field is true or false.

if false and isset($_POST['valid']) i show up the button

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

after i put the UPDATE query which change validated field from FALSE to true.

When the page is processed the if is ignored and was executed update query?

How can i fix this problem?

                <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

You are still in PHP mode when you write this line:

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

And where is your closing bracket for:

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