Making the Fields required in a Contact Form

3 replies
<?php
if(isset($_POST['submit'])) {

$myemail = "your-email-address@here.com";
$subject = $_POST['subject'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$headers = "From:Contact Form <$myemail>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";

echo "Your message has been sent successfully!";
mail($myemail, $subject, $message, $headers);

} else {

echo "An error occurred during the submission of your message";

}
?>

Anyone have any suggestions on what code I could add to make the fields in the above contact form required?

Thanks!
#contact #fields #form #making #required
Avatar of Unregistered
Avatar of Unregistered

Trending Topics