0

Every time it takes two clicks on the submit button to get the code to go, also just randomly it was triggering different codes that are setup the same way but with different names for the input and inside the $_POST. Am I using the $_POST right by setting the name of the input to the same thing?

here is the code

<?php                       
//If submit form was clicked
if(isset($_POST['intro'])) {
    //Server side validation for security purposes
    if($userpoints >= 100 AND $intro == 0 AND $lifeonmarsalbum == 0) {
        mysqli_query($con,"UPDATE users SET points = points - 100 WHERE users.user_name = '$username' LIMIT 1");
        mysqli_query($con,"UPDATE users SET intro = 1 WHERE users.user_name = '$username' LIMIT 1");
    }
}
?>
<form method="post" action="index.php">
    <?php
    if ($userpoints >= 100 AND $intro == 0 AND $lifeonmarsalbum == 0) {
        echo '<input type="submit" name="intro" value="100pts">';
    } elseif ($intro == 1 OR $lifeonmarsalbum == 1) {
        echo '<input type="submit" name="submit" value="100pts" disabled title="You already earned this track!">';
    } else {
        echo '<input type="submit" name="submit" value="100pts" disabled title="You need at least 100 points for this download">';
    }
    ?>
4

1 回答 1

2

name="intro"仅当满足第一行if()子句时才输出提交按钮。很可能在您第一次加载此页面时,不满足该条件,因此没有intro按钮。第一次提交后,条件满足,您进入name="intro"表单,然后提交“开始”工作。

于 2013-04-08T03:53:24.880 回答