Hi, I am completely new to php
I have a following php script running contact form for me
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_postalcode = $_POST['cf_postalcode'];
$field_telephone = $_POST['cf_telephone'];
$field_size = $_POST['cf_size'];
$field_bedrooms = $_POST['cf_bedrooms'];
$field_bathrooms = $_POST['cf_bathrooms'];
$field_startdate = $_POST['cf_startdate'];
$field_cats = $_POST['cf_cats'];
$field_dogs = $_POST['cf_dogs'];
$field_starttime = $_POST['cf_start'];
$field_estimate = $_POST['cf_estimate'];
$field_service = $_POST['cf_service'];
$field_frequency = $_POST['cf_frequency'];
$field_message = $_POST['cf_message'];
$mail_to = '
[email protected]';
$subject = 'Customer '.$field_name;
$body_message .= 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Postal Code: '.$field_postalcode."\n";
$body_message .= 'Telephone: '.$field_telephone."\n";
$body_message .= 'Size:' .$field_size."\n";
$body_message .= 'Bedrooms:' .$field_bedrooms."\n";
$body_message .= 'Bathrooms:' .$field_bathrooms."\n";
$body_message .= 'Start date:' .$field_startdate."\n";
$body_message .= 'Cats:' .$field_cats."\n";
$body_message .= 'Dogs:' .$field_dogs."\n";
$body_message .= 'Start time:' .$field_starttime."\n";
$body_message .= 'Estimate:' .$field_estimate."\n";
$body_message .= 'Service Type: '.$field_service."\n";
$body_message .= 'Cleaning Frequency: '.$field_frequency."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will contact you shortly.');
window.location = 'bookonline.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to
[email protected]');
window.location = 'bookonline.html';
</script>
<?php
}
?>
Now, I'd like to make some of the fields mandatory, what should I do? Is that going to be seperate script, or just addon to the existing one?
Thanks in advance