Contact Form not working

  You are currently not logged in. You can view the forums, but cannot post messages. Log In | Register

15-Jun-17 16:40
Can anyone PLEASE tell me why my contact form isnt working and how to make it secure? I have a php file on my server along with the form on my homepage index.html here is the php code saved in a php file called contact.php



<?php
$field_name = $_POST['name'];
$field_email = $_POST['email'];
$field_about = $_POST['about'];
$field_message = $_POST['message'];

// Replace with your email adress here
$mail_to = 'chauncey@meetmckenziemason.com';

$subject = 'Message from a site visitor '.$field_email;

$body_message = 'From: '.$field_name."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Talk about: '.$field_about."\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('Your message has been sent');
window.location = 'index.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed!');
window.location = 'index.html';
</script>
<?php
}
?>



And here is the form:


<form id="main-contact-form" action="contact.php" method="post" name="contact" >
<div class="field">
<p>Name <span class="colored">*</span></p>
<input name="name" type="text" class="required" title="Please type your name." placeholder="Name...">
</div>

<div class="field">
<p>Email address <span class="colored">*</span></p>
<input name="email" type="text" placeholder="Email...">
</div>

<div class="field">
<p>Subject</p>
<input name="about" type="text" placeholder="Subject...">
</div>

<div class="field">
<p>Type a message <span class="colored">*</span></p>
<textarea name="message" cols="15" rows="5" class="required" placeholder="Message..." title="Please type a message."></textarea>
</div>

<div class="button-container">
<button class="btn btn-submit" type="submit" name="submit">Send Message </button>
</div>

</form>



Also the web address is www.meetmckenziemason.com I used a simple html template that came with a mail form and its just not working. Can anyone help?

--
CW
16-Jun-17 04:22
Define "not working".

--
Chris.
So long, and thanks for all the fish.
http://webmaster-talk.eu/

 
New posts
Old posts

Follow Elated