sabregames sabregames - 3 months ago 35
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


$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$mail_to = '';
$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';
else { ?>
<script language="javascript" type="text/javascript">
alert('Message failed. Please, send an email to');
window.location = 'contact_page.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 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>


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'];