I have the following code in a php file ("form.php"), and it works fine (i have the form in an .shtml page, where form action="form.php" method="post">:
<?php
/* Subject and Email Variables */
$emailsubject = "$subject1, $subject2";
$webMaster = 'my@email.com';
/* Gathering Data Variables */
$name = $_POST['name'];
$surname = $_POST['surname'];
$email = $_POST['email'];
$number = $_POST['number'];
$street = $_POST['street'];
$zip = $_POST['zip'];
$city = $_POST['city'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$subject1 = $_POST['subject1'];
$subject2 = $_POST['subject2'];
$message = $_POST['message'];
$body = <<<EOT
Name: $name $surname
Email: $email
Number: $number
Street: $street
Postcode: $zip
City: $city
Contact Number: $phone
fax: $fax
Subjects: $subject1, $subject2
Message: $message
EOT;
$headers = "From: $email\r\n";
$headers .= "Content=type: text/html\r\n";
/* Emailing the Form */
mail($webMaster, $emailsubject, $body, $headers);
/* Directing the User to the Webpage thanks.html */
header('Location: success.shtml');
?>
HOWEVER
the fields are all optional, and I am able to receive empty emails.
what php code would help me with this?
Ideally, error messages would appear on the same .shtml page, not in a new window...
TIA from a total newbie!