php如何将if语句附加到按钮?

时间:2011-05-09 20:32:00

标签: php button isset

我有一份声明;

if($game_set->issue_challenge()){echo "test";}else {"test failed";}

我有一个按钮:

<input type="submit" name="submit" id="submit" value="Submit" />

我希望能够说:if the button isset, then $values = $_POST['gamelist'] and if($game_set->issue_challenge()){echo "test";}else {"test failed";}

我在想像

这样的东西
if (isset($_POST['Submit'])) {
$values = $_POST['gamelist']
if($game_set->issue_challenge()){echo "test";}else {"test failed";}
}

任何想法?

感谢

1 个答案:

答案 0 :(得分:1)

假设您正在使用POST表单:

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if (isset($_POST['submit']) && ($_POST['submit'] == 'Submit')) {
       ... it was clicked
    }
}