Use conditions and isset to check for the presence of form fields.
<?php
error_reporting(-1);
ini_set('display_errors', 'On');
// Check if all the fields are entered
if(isset($_POST['imie']) && isset($_POST['telefon']) && isset($_POST['email']) && isset($_POST['platnosc'])){
// Check if rules are agreed.
if(!isset($_POST['regulamin'])){
echo "Please accept our terms of services.";
die();
}
//Check if the email is valid
if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
//Kill the page if it's invalid
echo "Please enter a proper email address.";
die();
}
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "biuro@natropiegra.pl";
$email_subject = "POZIOM 1";
$email_from = "rezerwacja@natropiegra.pl";
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Imię i nazwisko: ".clean_string($_POST["imie"])."\n";
$email_message .= "Email: ".clean_string($_POST["email"])."\n";
$email_message .= "Telefon: ".clean_string($_POST["telefon"])."\n";
$email_message .= "Płatność: ".implode(" ", $_POST['platnosc'])."\n";
$email_message .= "Miesiąc: ".clean_string($_POST["miesiac"])."\n";
$email_message .= "Dzień: ".clean_string($_POST["dzien"])."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
<center>
<img src="image/natropie2.png" />
<br>
<br>
Thank you for contacting us. We will be in touch.<br>
<br>
<a href="index.html">HOME</a></center>
<?php
}else{
echo "Please fill all the fields properly.";
die();
}
?>