Avatar ·

How to check which HTTP method is used in PHP: GET or POST?

Hello everyone! I just started learning PHP and I'm writing a simple feedback form. I have one HTML page that contains the form and also processes the data (action="").\n\nThe problem is that when I simply navigate to the page (without submitting the form), PHP tries to process data from $_POST, which doesn't exist, and throws "Undefined array key" errors. How can I properly determine whether the request was GET (just opening the page) or POST (submitting the form)?\n\nHere is my current code:\n\n```php\n\n
\n Name:
\n Email: