Friday, January 24, 2020

How to check whether a request is GET or POST in PHP?

To determine whether the request arrive via GET or POST method use the following code.

PHP Code:

if ($_SERVER['REQUEST_METHOD'] === 'GET') {
    // .... Code for GET Request
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // .... Code for POST Request
}

No comments:

Post a Comment