Making the Fields required in a Contact Form

4 replies
if(isset($_POST['submit'])) {

$myemail = "";
$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?

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

Trending Topics