My form having Name, Email, Phone & Message field is not working. When I am submitting the form, blank page is opening with the php mail handler url. It should be showing the thank you message instead. Also no email is received at the email ID. Please help.
My HTML form code is
<form id="contactform" action="contact_form.php" method="POST">
<div>
<input type="text" class="form-control" placeholder="Name" name="name" required id="name">
</div>
<div>
<input type="email" class="form-control" placeholder="Email" name="email" required id="email">
</div>
<div>
<input type="text" class="form-control" placeholder="Phone" required name="phone" id="phone">
</div>
<textarea class="form-control" name="message" id="message" rows="4" placeholder="Enter Your Message" required></textarea>
<div class="text-center">
<button type="submit" value="submit" class="btn btn-default">SUBMIT</button>
</div>
</form>
PHP CODE FOR MAIL
<?php
if(isset($_POST['submit'])){
$to = "xyz@abc.com"; // this is your Email address
$from = $_POST['email']; // this is the sender's Email address
$name = $_POST['name'];
$phone = $_POST['phone'];
$subject = "Form submission";
$subject2 = "Copy of your form submission";
$message = "Name:". $name . "\n" . "Phone:" . $phone . "\n" . "\n" . "Message:" . "\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . "\n" . "Name:" . $name . "\n" . "Phone:" . $phone . "\n" . "\n" . "Message:" . "\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
echo "Mail Sent. Thank you, " . $name . ", we will contact you shortly.";
// You can also use header('Location: thank_you.php'); to redirect to another page.
// You cannot use header and echo together. It's one or the other.
}
?>
The form is on the bottom of this page https://www.delveindia.com/products/billing-software/