Hi I am creating a webpage and i am stuck at making a contact form. Whenever I click submit, the form send the information to my email but it would just send a blank email. No matter how I try, I just can't seem to get it to send properly😕. Please help! Thanks so much🙂! I have copied the html and php below:
HTML
<form id="ContactForm" action="contact.php" enctype="multipart/form-data"><div>
<div class="wrapper">
<span>Your Name:</span>
<input name="field_name" input type="text" class="input" >
</div>
<div class="wrapper">
<span>Your E-mail:</span>
<input name="field_email" input type="text" class="input">
</div>
<div class="textarea_box">
<span>Your Message:</span>
<textarea name="field_message" cols="5" rows="49"></textarea>
</div>
<a href=# class="button" onClick="document.getElementById('ContactForm').submit()"><strong onfocus="MM_popupMsg('Thanks for your enquiry. We aim to get back to you as soon as possible.')">Send</strong></a>
<a href="#" class="button" onClick="document.getElementById('ContactForm').reset()"><strong>Clear</strong></a>
</div>
</form>
PHP
<?php
$field_name = $_POST['field_name'];
$field_email = $_POST['field_email'];
$field_message = $_POST['field_message'];
$mail_to = 'thebluecheese@gmail.com';
$subject = 'Enquiry'.$field_name;
$body_message = 'Name: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Message: '.$field_message."\n";
$headers = 'From: '.$cf_email."\r\n";
$headers .= 'Reply-To: '.$cf_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for the message. We will be in contact with you shortly.');
window.location = 'contact.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to fleurfu777@gmail.com');
window.location = 'contact.html';
</script>
<?php
}
?>