开发者

php how to attach a if statement to a button?

开发者 https://www.devze.com 2023-03-03 20:33 出处:网络
I have a I statement; if($game_set->issue_challenge()){echo \"test\";}else {\"test failed\";} and I have a button:

I have a I statement;

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

and I have a button:

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

I want to be able to say: if the button isset, then $values = $_POST['gamelist'] and if($game_set->issue_challenge()){echo开发者_JAVA百科 "test";}else {"test failed";}

I was thinking something like

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

any ideas?

thanks


Assuming you're on a POST form:

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

精彩评论

暂无评论...
验证码 换一张
取 消