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!
$_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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With