I am new to PHP and I want to make it so every field is required to send the form. I've tried a few different ways but nothing seems to work. Below is the script with no required fields. Can anyone show me how this would be done? Thanks, Dave
<?php
$name = $_POST['name'] . ' ' . $_POST['lastname'];
$practicename = $_POST['practive-name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$postalcode = $_POST['postalcode'];
$phonenumber = $_POST['phone'];
$email_address = $_POST['email'];
$speciality = $_POST['speciality'];
$comments = $_POST['comments'];
if(empty($name) {
Print($name." must be filled in please go back and do it again you twit!");
}
$to = 'myemailaddress';
$subject = 'Web contact form';
$msg =
"Name: $name\n" .
"Address: $address\n" .
"City: $city\n" .
"State: $state\n" .
"Postal Code: $postalcode\n" .
"Phone: $phone\n" .
"E-Mail Address: $email\n" .
"Speciality: $speciality\n" .
"Comments: $comments\n";
mail ($to, $subject, $msg, 'From:' . $email);
echo 'Thank you for submitting the CMB contact form. We will contact you back shortly. <br />';
?>