I have a simple php email script below. I want to require all fields be filled out before sending. Also I want to check that phone and email input is in the appropriate format.
<?php
$to = "email@domain.com";
$from = "website@domain.com";
$name = $_REQUEST['name'] ;
$message = "Name: " .$name."\n\nBusiness or School Name:\n" .$_REQUEST['busname']. "\n\nAddress:\n" .$_REQUEST['address']."\n\
nPhone:\n"
.$_REQUEST['phone']."\n\nE
mail:\n" .$_REQUEST['email'];
$headers = "From: $from\r\nReply-To: " . $_REQUEST['email'];
$subject = "DEMO request";
$fields{"Name"} = "Name";
$fields{"Email"} = "Email";
if (!empty($to) && !empty($from) && !empty($message) && !empty($headers) && !empty($subject)) {
$send = mail($to, $subject, $message, $headers);
if($send) {
header("Location:
http://www.domain.com/emailsent.php"
);
exit;
}
}
header("Location:
http://www.domain.com/emailerror.php");
exit;
?>
Start Free Trial