I have made a simple contact form for my website with a validator, so users should enter all inputs before the contact form can be submitted. After submission, the user is directed to a php page, i.e. all contact information will then be send to mail. Unfortunately a user can bypass all the required inputs by just typing in the url of PHP. The result is an email with no inputs.
How can i prevent users access the URL of my PHP file: see current php code below
<?php
/* Subject and Email Variables */ 
$emailSubject = ''; 
$webMaster = '';
/* Gathering Data Variables */ 
$name = $_POST['Name']; 
$adress = $_POST['Adresse']; 
$email = $_POST['email']; 
$body = <<<EOD <br><hr<br> Name: $name <br> Adresse: $adress <br> Epost: $email <br> EOD; 
$headers = "From: $email\r\n"; $headers = "Content-type: text/html\r\n";    
$success = mail($webMaster, $emailSubject, $body, $headers); 
/* Results rendered as HTML */ 
$theResults = <<<EOD EOD; echo "$theResults";     
?>    
 
     
     
    
Adresse: $adress
Epost: $email
EOD; $headers = "From: $email\r\n"; $headers = "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* Results rendered as HTML */ $theResults = <<