This should work for you:
(If you press the GET
button you should get "From Method GET"
and if you press the POST
button you should get "From Method POST"
)
But you have to submit the form otherwise the Server will not react! You also have to make sure your file ends with .php
and is saved in the webserver.
Also you should have a webserver with PHP!
PHP:
<?php
if($_SERVER['REQUEST_METHOD'] == "POST"){
echo '<b>From Method POST</b>';
} elseif($_SERVER['REQUEST_METHOD'] == "GET"){
echo '<b>From Method GET</b>';
}
?>
HTML:
<form action="" method="post">
<input type="submit" name="submitButton1" value="POST">
</form>
<form action="" method="get">
<input type="submit" name="submitButton2" value="GET">
</form>
BTW for error messages use:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
?>
2
solved If server request method post echo html doesent work [closed]