I'm working on a Contact Form for my website. It works, except the "Phone" field doesn't show a phone number in the sent message. It's just blank where the number should be displayed.
What am I doing wrong?
- Thanks
HTML:
<div class="contact-form">
<h2 class="style">Contact Us</h2>
<form action="contact.php" method="post" id="form">
<div>
<span><label>NAME</label></span>
<span><input name="cf_name" type="text" class="textbox"></span>
</div>
<div>
<span><label>EMAIL</label></span>
<span><input name="cf_email" type="text" class="textbox"></span>
</div>
<div>
<span><label>PHONE</label></span>
<span><input name="cf_phone" type="text" class="textbox"></span>
</div>
<div>
<span><label>MESSAGE</label></span>
<span><textarea name="cf_message"> </textarea></span>
</div>
<div>
<span><input type="submit" value="Send"></span>
</div>
</form>
</div>
PHP:
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_phone = $_POST['cf_phone'];
$field_message = $_POST['cf_message'];
$mail_to = 'somebody@invalid.com';
$subject = 'Message from a website visitor '.$field_name;
$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Phone: '.$field_phone."\n";
$body_message .= 'Message: '.$field_message;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_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 contact you shortly.');
window.location = 'index.html';
</script>
<?php