Only allow access to PHP scripts from a form, not directly
snippet in htaccess

Only allow access to PHP scripts from a form, not directly

user6764

 if ($_SERVER['REQUEST_METHOD'] != 'POST') {
   exit;
 }

Only allow access to PHP scripts from a form, not directly

user7425

$firstName = '';
if(isset($_GET['firstName']))
    $firstName = $isset($_GET['firstName']);
// ...
if(trim($firstName) == '')
    //do something to handle an error, either set an error flag or die() with an appropriate message