Home>

I suddenly wondered, so I will ask you a question.
Thanks for your reply.

The condition of the first if statement contains form name = "check".
Since the method is POST and the name is check in me, it is interpreted as $_POST ['check'].

Therefore, if ($_POST ['able']) and if ($_POST ['wrong']) contained in the first if statement are
Is it okay to set the conditional expression of the if statement to $_POST ['able'] because the method is not specified? I am wondering.

However, what is worrisome is thatIs done for value, so is it okay to use $_POST ['able']? I feel that.

This is an ignorant question, but I would be grateful if you could answer it.

// Processing when check is POSTed
    if ($_ POST ['check']) {
        // Save data in data and current time in created when able is POSTed
        if ($_ POST ['able']) {
            $date = $db->prepare ('INSERT INTO posts SET member_id = ?, data = ?, created = now ()');
            $data->execute (array (
            $mem ['id'],
            $_SESSION ['join'] ['able']
            ));
        }
        //// When wrong is POSTed
        if ($_ POST ['wrong']) {
            $date = $db->prepare ('INSERT INTO posts SET member_id = ?, data = ?, created = now ()');
            $data->execute (array (
                $mem ['id'],
                $_POST ['wrong']
            ));
            $a ='aiueo';
        }
         header ('Location: main.php');
         exit ();
    }
<form action = "" method = "POST">
<Input type = "hidden" name = "check" value = "submit" />
<Button type = "submit" name = "able" value = "<? php print (htmlspecialchars ($_POST ['able'], ENT_QUOTES));?>">Done</button>
<button type = "submit" name = "wrong" value = "<? php print (htmlspecialchars ($_POST ['wrong'], ENT_QUOTES));?>">Failed</button>
</form>
  • Answer # 1

    It doesn't make sense to reset the button value from the post data
    Please set it statically.
    Since submits (buttons) can only be sent when pressed
    I think it can be separated