sabregames sabregames - 20 days ago 5
HTML Question

Contact form (Php and html

So I've been using a contact form, I created some php and html form but it sends everything to my email, except the email that the user puts in the form. Been trying all the stuff below, nothing works yet

PHP:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$mail_to = 'email@email.com';
$subject = 'Message from a site visitor '.$name;

$body_message = 'From: '.$name."\n";
$body_message .= 'E-mail: '.$email."\n";
$body_message .= 'Message: '.$message;

$headers = 'From: '.$email."\r\n";
$headers .= 'Reply-To: '.$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 = 'contact_page.html';
</script>
<?php
}
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to gordon@template-help.com');
window.location = 'contact_page.html';
</script>
<?php
}
?>


HTML:

<form action="contact.php" method="post">
<div class="row">
<div class="col-md-4">
<input type="text" class="form-control" id="name" placeholder="Name">
<input type="text" class="form-control" id="email" placeholder="Email">
<input type="text" class="form-control" id="subject" placeholder="Subject">
</div>


<div class="col-md-8">
<textarea class="form-control" id="message" rows="25" cols="10" placeholder=" Message Texts..."></textarea>
<button type="button" class="btn btn-default submit-btn form_submit">SEND MESSAGE</button>
</div>
</div>
</form>

Answer

After going through your script.js file, I finally figured out the problem. The variable sent is not email while its emaild. So your PHP correction would be:

$email = $_POST['emaild'];
Comments