I have been working with this for a couple days and have read thru MANY previously posed questions, as well as several tutorial sites... The Contact Form submits, confirms and redirects... It sends the email, with headers and subject line, to correct address... just NO inputs... no "FROM SENDER EMAIL", no FROM NAME INPUT, no EMAIL INPUT, no MESSAGE INPUT... HELP! So close, and yet so far... any advice is greatly appreciated ~ I write HTML & CSS, novice at JS and practically NO PHP experience... Thank You in Advance! :)
Here's the HTML contact-form:
<form action= "contact-form.php" id="contact-form" method="post">
<fieldset>
<label><input name="cf-name" type="text" value="Your Name" onBlur="if(this.value=='') this.value='Your Name'" onFocus="if(this.value =='Your Name' ) this.value=''" /></label>
<label>
<input name="cf-email" type="text" value="Email" onBlur="if(this.value=='') this.value='Email'" onFocus="if(this.value =='Email' ) this.value=''" />
</label>
<textarea name="cf-message" onBlur="if(this.value=='') this.value='Message'" onFocus="if(this.value =='Message' ) this.value=''">Message</textarea>
<div class="buttons">
<p><a href="#" onClick="document.getElementById('contact-form').reset()">Clear</a>
<a href="#" onClick="document.getElementById('contact-form').submit()">Send</a></p>
<p>
</p>
</div>
</fieldset>
</form>
and here is the PHP (contact-form.php):
<?php
$field_name = $_POST['cf_name'];
$field_email = $_POST['cf_email'];
$field_message = $_POST['cf_message'];
$mail_to = 'info@anelectrician.net';
$subject = 'Message from a website visitor...'.$field_name;
$body_message = 'From:'.$field_name."
";
$body_message .= 'E-mail:'.$field_email."
";
$body_message .= 'Message:'.$field_message;
$headers = 'From: '.$field_email."
";
$headers .= 'Reply-To: '.$field_email."
";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
if ($mail_status) { ?>
<script language="javascript" type="text/javascript">
alert('Thank you for your correspondence. We will contact you shortly.');
window.location = 'index.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to info@anelectrician.net');
window.location = 'contact.html';
</script>
<?php
}
?>