Better use $_SERVER['REQUEST_METHOD']: if ($_SERVER['REQUEST_METHOD'] === 'POST') { // … }
if($_SERVER['REQUEST_METHOD'] == 'POST') {}