As an mildly-intermediate web developer, I have never actually implemented a contact form until now. The problem is that I can't get the email to actually go through.
HTML:
<form action="php/handleFormSubmit.php" id="contact-form" role="form" method="POST">
<div class="ajax-hidden">
<div class="form-group wow fadeInUp">
<label class="sr-only" for="c_name">Name</label>
<input type="text" id="c_name" class="form-control" name="c_name" placeholder="Name">
</div>
<div class="form-group wow fadeInUp" data-wow-delay=".1s">
<label class="sr-only" for="c_email">Email</label>
<input type="email" id="c_email" class="form-control" name="c_email" placeholder="E-mail">
</div>
<div class="form-group wow fadeInUp" data-wow-delay=".2s">
<textarea class="form-control" id="c_message" name="c_message" rows="7" placeholder="Message"></textarea>
</div>
<button type="submit" class="btn btn-lg btn-block wow fadeInUp" data-wow-delay=".3s">Send Message</button>
</div>
<div class="ajax-response"></div>
</form>
PHP:
<?php
if(isset($_POST['submit']))
{
$name = $_POST['c_name'];
$visitor_email = $_POST['c_email'];
$message = $_POST['c_message'];
$email_from = "email@email.com";
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $message".
$to = "email@email.com";
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $visitor_email \r\n";
mail($to,$email_subject,$email_body,$headers);
}
if(isset($_POST['c_name'])){
$res['sendstatus'] = 1;
$res['message'] = 'Form Submission Successful';
echo json_encode($res);
}
?>
I know the if(isset($_POST['submit']))
gets rid of the annoying email when refreshing/landing but my submit does not go to my email.
Help? I appreciate it.