I am watching a video about PHP form submit, it mentions this method
if ($_SERVER["REQUEST_METHOD"] == "POST") {
/* code handle the form date */
}
I don't know why we should use that? Can someone explain for me? Thanks!
I am watching a video about PHP form submit, it mentions this method
if ($_SERVER["REQUEST_METHOD"] == "POST") {
/* code handle the form date */
}
I don't know why we should use that? Can someone explain for me? Thanks!
There are various methods of from submission like POST, GET, PUT, DELETE.
$_SERVER['REQUEST_METHOD'] holds the name of the method for a form submission. If you want to restrict your form processing only form POST type request, then you need to put that check.
$_SERVER['REQUEST_METHOD']
contains the request method. It is used to check request method.This variable also says if the request is a 'GET', 'HEAD', 'POST' or 'PUT' request.