PHP Form Submits But Does Not Display 1 Value - php

I have a PHP form that works except for 1 thing and I am going nuts trying to figure out how to make it work. It emails me the results, and everything displays in the email fine except the "Plus1" field is always blank. How can I get the value to display in the submitted email form? Thanks for your help.
You can see it live on http://michyandsmiley.com.
Here is the code for the form:
<div id="rsvp" class="text-center" data-scroll-reveal>
<div class="heading">
<h2>RSVP</h2>
<p><span></span><i class="fa fa-heart"></i><span></span></p>
</div>
<form role="form" name="contactform" action="process.php">
<div class="row">
<div id="name-group" class="form-group col-xs-12">
<label for="inputName">Your Name</label>
<input type="text" class="form-control" id="inputName" name="inputName" placeholder="John Doe">
</div>
</div>
<div class="row">
<div id="email-group" class="form-group col-xs-12">
<label for="inputEmail">Your Email</label>
<input type="email" class="form-control" id="inputEmail" name="inputEmail" placeholder="name#domain.com">
</div>
</div>
<div class="row">
<div id="guests-group" class="form-group col-xs-6">
<label for="selectGuests">Total Guests</label>
<select class="form-control" name="selectGuests" id="selectGuests">
<option value="1" selected>1</option>
<option value="2">2</option>
</select>
</div>
<div id="plusone-group" class="form-group col-xs-6">
<label for="inputPlus1">Guest's Name</label>
<input type="Plus1" class="form-control" id="inputPlus1" name="inputPlus1" placeholder="Jane Doe">
</div>
<div class="row">
<div id="attending-group" class="form-group col-xs-12">
<label for="selectAttending">I am...</label>
<select class="form-control" name="selectAttending" id="selectAttending">
<option value="Attending" selected>So excited to attend! Yay!</option>
<option value="Not Attending">Sorry to miss it. Boo!</option>
</select>
</div>
</div>
<div class="row">
<button type="submit" class="btn btn-lg">Submit Your RSVP!</button>
</div>
</form>
</div>
And for the "process.php" code:
<?php
$send_to = '(removed my email for privacy purposes)';
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
// validate the variables ======================================================
// if any of these variables don't exist, add an error to our $errors array
if (empty($_POST['inputName']))
$errors['name'] = 'Name is required.';
if (empty($_POST['inputEmail']))
$errors['email'] = 'Email is required.';
// return a response ===========================================================
// if there are any errors in our errors array, return a success boolean of false
if ( ! empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
} else {
// if there are no errors process our form, then return a message
//If there is no errors, send the email
if( empty($errors) ) {
$subject = 'Wedding RSVP Form';
$headers = 'From: ' . $send_to . "\r\n" .
'Reply-To: ' . $send_to . "\r\n" .
'X-Mailer: PHP/' . phpversion();
$message = 'Name: ' . $_POST['inputName'] . '
Email: ' . $_POST['inputEmail'] . '
Guests: ' . $_POST['selectGuests'] . '
GuestName: ' . $_POST['inputPlus1'] . '
Attending: ' . $_POST['selectAttending'];
$headers = 'From: RSVP Form' . '<' . $send_to . '>' . "\r\n" . 'Reply-To: ' . $_POST['inputEmail'];
mail($send_to, $subject, $message, $headers);
}
// show a message of success and provide a true success variable
$data['success'] = true;
$data['message'] = 'Thank you!';
}
// return all our data to an AJAX call
echo json_encode($data);

You don't have the field in the field list to post to the server:
var formData = {
'inputName' : $('input[name=inputName]').val(),
'inputEmail' : $('input[name=inputEmail]').val(),
'selectGuests' : $('select[name=selectGuests]').val(),
'selectAttending' : $('select[name=selectAttending]').val()
};

Related

PHP Onsubmit send email

I have a form where a receptionist enters a visitors information, first name, email etc and I want to send an email to the visitor using their email address entered in the form.
I have the php mail function working however it currently only sends to a specific sender that I manually specify. How do I make the submit button on this form send an email based on the contents of the email field?
I assume I need to do something like this
<?php
$to = $row['email'];
$subject = 'Welcome ' . $row['first_name'] . ';
$message = 'You have been booked in';
$headers = 'From: noreply#blah.com' . "\r\n" .
'Reply-To: noreply#blah.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>
I dont think the $row[] is correct as I want to pull from the form, not the table that the form is inputting into.
This is the form page:
//serve POST method, After successful insert, redirect to customers.php page.
if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
//Mass Insert Data. Keep "name" attribute in html form same as column name in mysql table.
$data_to_store = filter_input_array(INPUT_POST);
//Insert timestamp
$db = getDbInstance();
$last_id = $db->insert ('tb_bookings', $data_to_store);
if($last_id)
{
$_SESSION['success'] = "Visitor signed in successfully!";
header('location: bookings.php');
exit();
}
}
//We are using same form for adding and editing. This is a create form so declare $edit = false.
$edit = false;
require_once('includes/admin-header.php');
?>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h2 class="page-header">Manual Sign-in</h2>
</div>
</div>
<form class="form" action="" method="post" id="visitor_form" enctype="multipart/form-data">
<?php include_once('../forms/prebook_form.php'); ?>
</form>
</div>
And this is the form:
<fieldset>
<div class="form-group">
<label for="f_name">First Name *</label>
<input type="text" name="first_name" value="<?php echo $edit ? $tb_bookings['first_name'] : ''; ?>" placeholder="First Name" class="form-control" required="required" id = "first_name" >
</div>
<div class="form-group">
<label for="l_name">Last name *</label>
<input type="text" name="last_name" value="<?php echo $edit ? $tb_bookings['last_name'] : ''; ?>" placeholder="Last Name" class="form-control" required="required" id="last_name">
</div>
<div class="form-group">
<label for="email">Email</label>
<input type="email" name="email" value="<?php echo $edit ? $tb_bookings['email'] : ''; ?>" placeholder="E-Mail Address" class="form-control" id="email">
</div>
<div class="form-group">
<label>Visiting Date</label>
<input name="visiting_date" value="<?php echo $edit ? $tb_bookings['visiting_date'] : ''; ?>" placeholder="Visiting Date" class="form-control" type="date">
</div>
<div class="form-group">
<label>Visiting</label>
<input name="visiting" value="<?php echo $edit ? $tb_bookings['visiting_date'] : ''; ?>" placeholder="Who are they visiting?" class="form-control" id="visiting">
</div>
<div class="form-group text-center">
<label></label>
<button type="submit" class="btn btn-warning" >Save <span class="glyphicon glyphicon-send"></span></button>
</div>
</fieldset>
maybe something like this...
if (isset($_POST['submit'])) {
$to = $_POST['email'];
$name = $_POST['first_name'];
$subject = 'Welcome ' . $name;
$message = 'You have been booked in';
$headers = 'From: noreply#blah.com' . "\r\n" .
'Reply-To: noreply#blah.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}

PHP How can i include a var in my mail message?

Good Day,
I have a form that saves Name, Email, Subject, Tel Number, Message, and a checkbox.
I m sadly not so good in php at all. Im just started to learn the basics. Thats why i need a little help from you :)
The Form
<form class="contact-form" id="contact" role="form">
<!-- IF MAIL SENT SUCCESSFULLY -->
<h6 class="success">
<span class="olored-text icon_check"></span> Your Message has been send. </h6>
<!-- IF MAIL SENDING UNSUCCESSFULL -->
<h6 class="error">
<span class="colored-text icon_error-circle_alt"></span> Error </h6>
<div class="field-wrapper col-md-6">
<input class="form-control input-box" id="cf-name" type="text" name="cf-name" placeholder="Name*" required>
</div>
<div class="field-wrapper col-md-6">
<input class="form-control input-box" id="cf-email" type="email" name="cf-email" placeholder="E-Mail*" required>
</div>
<div class="field-wrapper col-md-6">
<input class="form-control input-box" id="cf-subject" type="text" name="cf-subject" placeholder="Subject*" required>
</div>
<div class="field-wrapper col-md-6">
<input class="form-control input-box" id="cf-number" type="tel" name="cf-number" placeholder="Number">
</div>
<div class="field-wrapper col-md-12">
<textarea class="form-control textarea-box" id="cf-message" rows="7" name="cf-message" placeholder="Message*" required></textarea>
</div>
<div class="form-check col-md-12">
<input type="checkbox" class="form-check-input" id="Checkdata" required>
<label class="form-check-label" for="Checkdata"> yes to this*</label>
</div>
<div class="col-md-12 ">
<p>*required</p>
</div>
<button class="btn standard-button" type="submit" id="cf-submit" name="submit" data-style="expand-left">Send</button>
</form>
Now i need this information: Name, Subject, Email, Number and if the checkbox was checked. I would like to include the Number and the checkbox info in the message, that will send as a email to me, because the Name, Subject and Email info will go in the email header.
I figured out how i could save all to the header, but im not really sure about how to include something in the message. Do i have to sent a HTML email for that? or can i do it without html?
There goes my php code
<?php
if ( isset($_POST['email']) && isset($_POST['name']) && isset($_POST['subject']) && isset($_POST['number']) && isset($_POST['message']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {
$test = "/(content-type|bcc:|cc:|to:)/i";
foreach ( $_POST as $key => $val ) {
if ( preg_match( $test, $val ) ) {
exit;
}
}
$headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>' . "\r\n" .
'Reply-To: ' . $_POST["email"] . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail( "hey#example.net", $_POST['subject'], $_POST['message'], $headers );
}
?>
Thank you all for your help.
Your question is not clear but assuming you want to append more text to the message?
You can do something like this:
$more_message = $_POST['name']. "hello, this is more \n";
mail( "hey#example.net", $_POST['subject'], $more_message.$_POST['message'], $headers );
Update based on comment below on additional requirements:
$header_1 = $_POST['subject'] ."\n" .$_POST['name'] ."\n";
$more_message = $_POST['message']. "\n". $_POST['number'] ."\n". $_POST['Checkdata'];
something like this...

Display form error message on form page

I am trying to display php error message on same page as form but unable to print this.
Form is working and error message is also showing up but the problem is only form redirect on another page.
Here is form.php
<form action="contact_mail.php" method="post" name="contact_Form" id="contactform">
<div class="row">
<div class="col-md-12 page_subtitle">Get in Touch</div>
</div>
<div class="row mt-30">
<div class="col-md-12 form-group"><input type="text" value="<?php if (isset($errors['name_co'])): echo $errors; endif; ?>" placeholder="Name" class="form-control" name="name_co" ></div>
</div>
<div class="row">
<div class="col-md-6 form-group"><input type="text" id="txtEmail" value="" placeholder="Email ID" class="form-control" name="email_co" pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,63}$" required /></div>
<div class="col-md-6 form-group"><input type="text" value="" placeholder="Phone Number" class="form-control" name="mobile" pattern="[789][0-9]{9}" required /></div>
</div>
<div class="row">
<div class="col-md-12 form-group"><textarea cols="45" rows="6" placeholder="Message" class="form-control" name="comments_co" required/></textarea></div>
</div>
<div class="row">
<div class="col-md-12 form-group"><?php
$a_con=rand(0,9);
$b_con=rand(0,9);
?>
Human Test <?php echo $a_con." + ".$b_con?> =
</div>
</div>
<div class="row">
<div class="col-md-12 form-group"><input type="text" value="" placeholder="Human Test" class="form-control" name="value_num" required/>
<input class="input" name="captcha_num_hidden_contact" id="captcha_num_hidden_contact" type="hidden" value="<?php echo $a_con+$b_con;?>"/>
</div>
</div>
<div class="row">
<div class="col-md-12 form-group"><input type="submit" name="submit" class="btn btn-submit" /></div>
</div>
</form>
And here is
contact_mail.php
<?php
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
//error_reporting(0);
// validate the variables ======================================================
// if any of these variables don't exist, add an error to our $errors array
if (isset($_POST['submit'])){
if (empty($_POST['name_co']))
$errors['name_co'] = 'Name is required.';
if (empty($_POST['email_co']))
$errors['email_co'] = 'Email is required.';
if (empty($_POST['mobile'])){
$errors['mobile'] = 'Mobile no is required.';
} else if(strlen((string)$_POST['mobile']) < 10){
$errors['mobile'] = 'Please enter a valid Mobil No.';
}
if (empty($_POST['comments_co']))
$errors['comments_co'] = 'Comments is required.';
if (empty($_POST['value_num'])) {
$errors['value_num'] = 'Human Test is required.';
}
else if ($_POST['captcha_num_hidden_contact'] != $_POST['value_num']) {
$errors['captcha_num_hidden_contact'] = 'Please enter the correct result.';
}
}
// return a response ===========================================================
// if there are any errors in our errors array, return a success boolean of false
if (!empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
} else {
// if there are no errors process our form, then return a message
// DO ALL YOUR FORM PROCESSING HERE
// THIS CAN BE WHATEVER YOU WANT TO DO (LOGIN, SAVE, UPDATE, WHATEVER)
$email_subject = 'Query From Contact Us';
// $message = '<div><strong>Query From Contact Us : </strong></div>';
// $message .= '<div>---------------------------------------- </div>';
// $message .= '<div><strong>Name: </strong>' . $_POST['name_co'] . '</div>';
// $message .= '<div><strong>Email: </strong>' . $_POST['email_co'] . '</div>';
// $message .= '<div><strong>Service: </strong>' . $_POST['option_type'] . '</div>';
// $message .= '<div><strong>Subject: </strong>' . $_POST['subject_co'] . '</div>';
// $message .= '<div><strong>Mobile: </strong>' . $_POST['mobile'] . '</div>';
// $message .= '<div><strong>Comments: </strong>' . $_POST['comments_co'] . '</div>';
$email_subject1 = 'Acknowledgement';
$headers1 = "MIME-Version: 1.0\r\n";
$headers1 .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers1 .= "From: "."\r\n";
$mailstatus1 = mail($_POST['email_co'], $email_subject1, $message1, $headers1, "");
// show a message of success and provide a true success variable
$data['success'] = true;
$data['message'] = 'Your Query has been successfully submit. We will contact you very soon!!';
header("location:thank-you.php");
exit;
}
//echo json_encode($data);
// return all our data to an AJAX call
My main problem is that I want to print the error message on the form page but I was unable to print it.
As mentioned in comments I implemented your code on one page.
changed your
<form action="contact_mail.php" method="post" name="contact_Form" id="contactform">
into
<form target="_self" method="post" name="contact_Form" id="contactform" enctype="multipart/form-data">
and added printing errors as in #Bernhard Answer
echo implode('<br>', $data['errors']);
Also changed pattern in this line
<div class="col-md-6 form-group"><input type="text" value="" placeholder="Phone Number" class="form-control" name="mobile" pattern="[123456789]{9}" required /></div>
I am just going to say that when you will be ready consider user input validation in php not just html and using library for sending email such as PHPMailer.
Here is whole code
<?php
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
//error_reporting(0);
// validate the variables ======================================================
// if any of these variables don't exist, add an error to our $errors array
if (isset($_POST['submit'])){
if (empty($_POST['name_co']))
$errors['name_co'] = 'Name is required.';
if (empty($_POST['email_co']))
$errors['email_co'] = 'Email is required.';
if (empty($_POST['mobile'])){
$errors['mobile'] = 'Mobile no is required.';
} else if(strlen((string)$_POST['mobile']) < 10){
$errors['mobile'] = 'Please enter a valid Mobil No.';
}
if (empty($_POST['comments_co']))
$errors['comments_co'] = 'Comments is required.';
if (empty($_POST['value_num'])) {
$errors['value_num'] = 'Human Test is required.';
}
else if ($_POST['captcha_num_hidden_contact'] != $_POST['value_num']) {
$errors['captcha_num_hidden_contact'] = 'Please enter the correct result.';
}
}
// return a response ===========================================================
// if there are any errors in our errors array, return a success boolean of false
if (!empty($errors)) {
// if there are items in our errors array, return those errors
$data['success'] = false;
$data['errors'] = $errors;
echo implode('<br>', $data['errors']);
} else {
// if there are no errors process our form, then return a message
// DO ALL YOUR FORM PROCESSING HERE
// THIS CAN BE WHATEVER YOU WANT TO DO (LOGIN, SAVE, UPDATE, WHATEVER)
$email_subject = 'Query From Contact Us';
// $message = '<div><strong>Query From Contact Us : </strong></div>';
// $message .= '<div>---------------------------------------- </div>';
// $message .= '<div><strong>Name: </strong>' . $_POST['name_co'] . '</div>';
// $message .= '<div><strong>Email: </strong>' . $_POST['email_co'] . '</div>';
// $message .= '<div><strong>Service: </strong>' . $_POST['option_type'] . '</div>';
// $message .= '<div><strong>Subject: </strong>' . $_POST['subject_co'] . '</div>';
// $message .= '<div><strong>Mobile: </strong>' . $_POST['mobile'] . '</div>';
// $message .= '<div><strong>Comments: </strong>' . $_POST['comments_co'] . '</div>';
$email_subject1 = 'Acknowledgement';
$headers1 = "MIME-Version: 1.0\r\n";
$headers1 .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
$headers1 .= "From: "."\r\n";
$mailstatus1 = mail($_POST['email_co'], $email_subject1, $message1, $headers1, "");
// show a message of success and provide a true success variable
$data['success'] = true;
$data['message'] = 'Your Query has been successfully submit. We will contact you very soon!!';
//header("location:thank-you.php");
}
?>
<form target="_self" method="post" name="contact_Form" id="contactform" enctype="multipart/form-data">
<div class="row">
<div class="col-md-12 page_subtitle">Get in Touch</div>
</div>
<div class="row mt-30">
<div class="col-md-12 form-group"><input type="text" value="<?php if (isset($errors['name_co'])): echo $errors; endif; ?>" placeholder="Name" class="form-control" name="name_co" ></div>
</div>
<div class="row">
<div class="col-md-6 form-group"><input type="text" id="txtEmail" value="" placeholder="Email ID" class="form-control" name="email_co" pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,63}$" required /></div>
<div class="col-md-6 form-group"><input type="text" value="" placeholder="Phone Number" class="form-control" name="mobile" pattern="[123456789]{9}" required /></div>
</div>
<div class="row">
<div class="col-md-12 form-group"><textarea cols="45" rows="6" placeholder="Message" class="form-control" name="comments_co" required/></textarea></div>
</div>
<div class="row">
<div class="col-md-12 form-group"><?php
$a_con=rand(0,9);
$b_con=rand(0,9);
?>
Human Test <?php echo $a_con." + ".$b_con?> =
</div>
</div>
<div class="row">
<div class="col-md-12 form-group"><input type="text" value="" placeholder="Human Test" class="form-control" name="value_num" required/>
<input class="input" name="captcha_num_hidden_contact" id="captcha_num_hidden_contact" type="hidden" value="<?php echo $a_con+$b_con;?>"/>
</div>
</div>
<div class="row">
<div class="col-md-12 form-group"><input type="submit" name="submit" class="btn btn-submit" /></div>
</div>
</form>
The solution is simple. You only need to output the Array with the errors below
if (!empty($errors)) {
You can do this like so:
echo implode('<br>', $data['errors']);
implode() will put the array together to a string. is put between each array-element when it is imploded.

Page is not redirecting to the php page from Html, when send button click in the web form?

When I try to click sent button, the content from the webpage is not redirecting to the .php page.I am using recaptcha in the form .Can you please help me to solve this issue..
my HTML code is:
<form action="sendform.php" id="contact-form" class="form-horizontal"
method="post">
<fieldset>
<div class="form-group">
<label class="col-sm-4 control-label" for="name">Your Name</label>
<div class="col-sm-8">
<input type="text" placeholder="Your Name" class="form-control" name="name" id="name">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="email">Email Address</label>
<div class="col-sm-8">
<input type="text" placeholder="Enter Your Email Address" class="form-control" name="email" id="email">
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="subject">Subject</label>
<div class="col-sm-8">
<input type="text" placeholder="Subject" class="form-control" name="subject" id="subject" list="exampleList">
<datalist id="exampleList" >
<option value="a">A</option>
<option value="b">B Combo</option>
</datalist>
</div>
</div>
<div class="form-group">
<label class="col-sm-4 control-label" for="message">Your Message</label>
<div class="col-sm-8">
<textarea placeholder="Please Type Your Message" class="form-control" name="message" id="message" rows="3"></textarea>
</div>
</div>
<div class="col-sm-8" class="form-group" class="g-recaptcha" data-sitekey="xxxxxxyyyyyyy"></div>
<div class="col-sm-offset-4 col-sm-8">
<button type="submit" value="Send" id="submit" name="submit" class="submit_btn float_l">Submit</button>
<button type="reset" class="btn btn-primary">Cancel</button>
</div>
</fieldset>
</form>
And my PHP Code sendform.php
<?php
if (isset($_POST['submit']) && !empty($_POST['submit'])):
if (isset($_POST['g-recaptcha-response']) && !empty($_POST['g-recaptcha-response'])):
//your site secret key
$secret = 'xxxxxxxxxxxxx';
//get verify response data
$verifyResponse = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . $secret . '&response=' . $_POST['g-recaptcha-response']);
$responseData = json_decode($verifyResponse);
if ($responseData->success):
$to = "aaa#abc.com"; // this is your Email address
$from = !empty($_POST['email']) ? $_POST['email'] : ''; // this is the sender's Email address
$name = !empty($_POST['name']) ? $_POST['name'] : '';
$subject = !empty($_POST['subject']) ? $_POST['subject'] : '';
$subject2 = "Copy of your form submission";
$message = $first_name . " " . $last_name . " wrote the following:" . "\n\n" . $_POST['message'];
$message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message'];
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers = "From:" . $from;
$headers .= 'From:' . $name . ' <' . $from . '>' . "\r\n";
$headers2 = "From:" . $to;
mail($to, $subject, $message, $headers);
$succMsg = 'Your request have submitted successfully.';
else:
$errMsg = 'Robot verification failed, please try again.';
endif;
else:
$errMsg = 'Please click on the reCAPTCHA box.';
endif;
else:
$errMsg = '';
$succMsg = '';
endif;
?>
I have tested your code and it works.
Please make sure that you have placed your html and php files in same directory and also your files should be served via a local running server.
So your url should look like this http://localhost/testing/index.html
Although, your sendform.php gives me captcha error ofcourse.
"Please click on the reCAPTCHA box."

PHP form sends but "No Sender"

I am able to receive email with all the information except for the email address that is entered in the form, and when I receive the email, I get "No Sender" instead of the person's name or email.
This is my HTML:
<!-- Contact Form -->
<div class="col-xs-12 col-sm-8 col-md-8">
<div id="contant-form-bx" class="contant-form-bx">
<div class="contact-loader"></div>
<form action="mail.php" id="contact-form" class="contact-form" name="cform" method="post">
<div class="row">
<div class="col-md-6">
<label for="name" id="name_label">Name</label>
<span class="name-missing">Please enter your name!</span>
<input id="name" type="text" value="" name="name" size="30">
</div>
<div class="col-md-6 columns">
<label for="e-mail" id="email_label">Email</label>
<span class="email-missing">Please enter a valid e-mail!</span>
<input id="e-mail" type="text" value="" name="email" size="30">
</div>
<div class="col-md-12">
<label for="message" id="phone_label">Message</label>
<span class="message-missing">Say something!</span>
<textarea id="message" name="message" rows="7" cols="40"></textarea>
</div>
<div class="col-md-12 text-center">
<input type="submit" name="submit" class="button" id="submit_btn" value="Send Message">
</div>
</div>
</form>
</div>
</div>
This is my PHP:
<?php
// declare our variables
$name = $_POST['name'];
$email = $_POST['e-mail'];
$message = nl2br($_POST['message']);
// set a title for the message
$subject = "From $name via WEB";
$body = "From $name, \n\n$message";
$headers = 'From: '.$email.'' . "\r\n" .
'Reply-To: '.$email.'' . "\r\n" .
'Content-type: text/html; charset=utf-8' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
// put your email address here
mail("info#wziel.com", $subject, $body, $headers);
?>
<!--Display a Thank you message in the callback -->
<div class="mail_response">
<h4>Thank you <?php echo $name ?>!</h4>
<p>I'll be in touch real soon!</p>
</div>
According to your form this:
$email = $_POST['e-mail'];
Should be this:
$email = $_POST['email'];
You have e-mail as the id not the name.
The php looks at name and not id
You're using $_POST['e-mail']. e-mail is the ID of the <input> tag. You should be using $_POST['email'] because name="email".

Categories