Form shows blank page on submit - php

I have been though the other questions and and nothing seems to help me!
I managed to get a thank you message using a previous help thread but that never resulted in an email. Please help me!
Html Code
<form name="AberdaronApplication" method="post" action="submit.php">
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="ContactName">Main Contact Name</label>
<input type="text" name="ContactName" class="form-control main" id="ContactName" placeholder="Main Contact Name">
<label class="sr-only" for="FirstAddress">AddressFirstLine</label>
<input type="text" name="FirstAddress" class="form-control main" id="FirstAddress" placeholder="First Line of Address">
</div>
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="HomeNumber">Home Number</label>
<input type="tel" name="HomeNumber" class="form-control" id="HomeNumber" placeholder="Home Telephone">
<label class="sr-only" for="SecondAddress">Second Line of Address</label>
<input type="text" name="SecondAddress" class="form-control" id="SecondAddress" placeholder="Second Line of Address">
</div>
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="MobileNumber">Mobile Number</label>
<input type="tel" name="MobileNumber" class="form-control" id="MobileNumber" placeholder="Mobile Number">
<label class="sr-only" for="City">City</label>
<input type="text" name="City" class="form-control" id="City" placeholder="City">
</div>
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="Email">Email Address</label>
<input type="email" name="Email" class="form-control" id="Email" placeholder="Email Address">
<label class="sr-only" for="PostCode">Post Code</label>
<input type="text" name="PostCode" class="form-control" id="PostCode" placeholder="Post Code">
</div>
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="dob">dob</label>
<input type="date" name="dob" class="form-control dob" id="dob" placeholder="Date of Birth">
<label class="sr-only" for="age">Age</label>
<input type="number" name="age" class="form-control age" id="age" placeholder="Age">
<label class="sr-only" for="allergy">allergy</label>
<input type="text" name="allergy" class="form-control ale" id="allergy" placeholder="Allergies/Medical Info">
</div>
</div>
<br />
<p class="Left">Details of Attendees<br />
<small>Leave fields blank if no attendees and scroll down to Details of Accommodation</small></p>
<div class="form-group">
<label class="sr-only" for="Contact1">Attendee Name</label>
<input type="text" name="Contact1" class="form-control main" id="Contact1" placeholder="Attendee Name">
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="dob1">dob</label>
<input type="date" name="dob1" class="form-control dob" id="dob1" placeholder="Date of Birth">
<label class="sr-only" for="age1">age</label>
<input type="number" name="age1" class="form-control age" id="age1" placeholder="Age">
<label class="sr-only" for="allergy1">allergy</label>
<input type="text" name="allergy1" class="form-control ale" id="allergy1" placeholder="Allergies/Medical Info">
</div>
</div>
<br />
<div class="form-group">
<label class="sr-only" for="Contact2">Attendee Name</label>
<input type="text" name="Contatc2" class="form-control main" id="Contact2" placeholder="Attendee Name">
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="dob2">dob</label>
<input type="date" name="dob2" class="form-control dob" id="dob2" placeholder="Date of Birth">
<label class="sr-only" for="age2">age</label>
<input type="number" name="age2" class="form-control age" id="age2" placeholder="Age">
<label class="sr-only" for="allergy2">allergy</label>
<input type="text" name="allergy2" class="form-control ale" id="allergy2" placeholder="Allergies/Medical Info">
</div>
</div>
<br />
<div class="form-group">
<label class="sr-only" for="Contact3">Attendee Name</label>
<input type="text" name="Contact3" class="form-control main" id="Contact3" placeholder="Attendee Name">
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="dob3">dob</label>
<input type="date" name="dob3" class="form-control dob" id="dob3" placeholder="Date of Birth">
<label class="sr-only" for="age3">age</label>
<input type="number" name="age3" class="form-control age" id="age3" placeholder="Age">
<label class="sr-only" for="allergy3">allergy</label>
<input type="text" name="allergy3" class="form-control ale" id="allergy3" placeholder="Allergies/Medical Info">
</div>
</div>
<br />
<div class="form-group">
<label class="sr-only" for="Contact4">Attendee Name</label>
<input type="text" name="Contact4" class="form-control main" id="Contact4" placeholder="Attendee Name">
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="dob4">dob</label>
<input type="date" name="dob4" class="form-control dob" id="dob4" placeholder="Date of Birth">
<label class="sr-only" for="age4">age</label>
<input type="number" name="age4" class="form-control age" id="age4" placeholder="Age">
<label class="sr-only" for="allergy4">allergy</label>
<input type="text" name="allergy4" class="form-control ale" id="allergy4" placeholder="Allergies/Medical Info">
</div>
</div>
<br />
<div class="form-group">
<label class="sr-only" for="Contact5">Attendee Name</label>
<input type="text" name="Contact5" class="form-control main" id="Contact5" placeholder="Attendee Name">
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="dob5">dob</label>
<input type="date" name="dob5" class="form-control dob" id="dob5" placeholder="Date of Birth">
<label class="sr-only" for="age5">age</label>
<input type="number" name="age5" class="form-control age" id="age5" placeholder="Age">
<label class="sr-only" for="allergy5">allergy</label>
<input type="text" name="allergy5" class="form-control ale" id="allergy5" placeholder="Allergies/Medical Info">
</div>
</div>
<br />
<div class="form-group">
<label class="sr-only" for="Contact6">Attendee Name</label>
<input type="text" name="Contact6" class="form-control main" id="Contact6" placeholder="Attendee Name">
</div>
<div class="form-group">
<div class="form-inline">
<label class="sr-only" for="dob6">dob</label>
<input type="date" name="dob6" class="form-control dob" id="dob6" placeholder="Date of Birth">
<label class="sr-only" for="age6">age</label>
<input type="number" name="age6" class="form-control age" id="age6" placeholder="Age">
<label class="sr-only" for="allergy6">allergy</label>
<input type="text" name="allergy6" class="form-control ale" id="allergy6" placeholder="Allergies/Medical Info">
</div>
</div>
<br />
<p class="Left">Details of Accommodation</p>
<div class="form-group">
<select class="form-control">
<option>Camp Pod</option>
<option>Camp Tent</option>
<option>Own Tent</option>
<option>Own Caravan </option>
</select>
</div>
<input type="submit" value="submit" id="submit" class="btn btn-success">Book Place</input>
</form>
PHP Code
<?php
$ContactName = $_POST['ContactName'];
$FirstAddress = $_POST['FirstAddress'];
$SecondAddress = $_POST['SecondAddress'];
$City = $_POST['City'];
$Postcode = $_POST['Postcode'];
$HomeNumber = $_POST['HomeNumber'];
$MobileNumber = $_POST['MobileNumber'];
$Email = $_POST['Email'];
$Contact1 = $_POST['Contact1'];
$dob1 = $_POST['dob1'];
$age1 = $_POST['age1'];
$allergy1 = $_POST['allergy1'];
$Contact2 = $_POST['Contact2'];
$dob2 = $_POST['dob2'];
$age2 = $_POST['age2'];
$allergy2 = $_POST['allergy2'];
$Contact3 = $_POST['Contact3'];
$dob3 = $_POST['dob3'];
$age3 = $_POST['age3'];
$allergy3 = $_POST['allergy3'];
$Contact4 = $_POST['Contact4'];
$dob4 = $_POST['dob4'];
$age4 = $_POST['age4'];
$allergy4 = $_POST['allergy4'];
$Contact5 = $_POST['Contact5'];
$dob5 = $_POST['dob5'];
$age5 = $_POST['age5'];
$allergy5 = $_POST['allergy5'];
$Contact6 = $_POST['Contact6'];
$dob6 = $_POST['dob6'];
$age6 = $_POST['age6'];
$allergy6 = $_POST['allergy6'];
$formcontent = $ContactName . "\n" . $FirstAddress . "\n" . $SecondAddress . "\n" . $City . "\n" . $Postcode . "\n" . $HomeNumber . "\n" . $MobileNumber . "\n" . $Email . "\n" . $Contact1 . "\n" . $dob1 . "\n" . $age1 . "\n" . $allergy1 . "\n" . $Contact2 . "\n" . $dob2 . "\n" . $age2 . "\n" . $allergy2 . "\n" . $Contact3 . "\n" . $dob3 . "\n" . $age3 . "\n" . $allergy3 . "\n" . $Contact4 . "\n" . $dob4 . "\n" . $age4 . "\n" . $allergy4 . "\n" . $Contact5 . "\n" . $dob5 . "\n" . $age5 . "\n" . $allergy5 . "\n" . $Contact6 . "\n" . $dob6 . "\n" . $age6 . "\n" . $allergy6;
$to = 'myemail#me.com';
$subject = "Aberdaron Camp Booking";
$mailheader = "From:" $ContactName "\r \n";
if (isset($_POST['submit']))
{
if (mail($to, $subject, $formcontent, $mailheader))
{
echo '<p>Your message has been sent!</p>';
}
else
{
echo '<p>Something went wrong, go back and try again!</p>';
}
}
?>

You didn't put name="ContactName" in any of your <input type="text".... post get the input values from name and not from id put name in every of your input and select <input type="text" name="put field name here"...> and select name="name here".
your code should be something like :
<input type="number" name="age5" class="form-control age" id="age5" placeholder="Age">
and concatenate (.) line break in $formcontent like :
$formcontent = $ContactName . "\n" . $FirstAddress ."\n" . $so_on ;
Update
Expand your headers
$mailheader = "From: noreply#site.com\r\n";
$mailheader .= "MIME-Version: 1.0\r\n";
$mailheader .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$mailheader .= "X-Priority: 1\r\n";

Needed to add and if Server request as follows:
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$ContactName...
And adding some more concatenates
$headers = 'From: '.$ContactName."\r\n" . 'Reply-To: '.$ContactName."\r\n";
Problem solved

Related

Why is sending data to local server using wamp unsuccessful?

<form role="form" action="" method="post">
<div class="form-group">
<label class="sr-only" for="form-username">First Name:</label>
<input type="text" name="firstname" placeholder="First Name" class="form-username form-control" id="form-username" required="">
</div>
<div class="form-group">
<label class="sr-only" for="form-username">Middle Name:</label>
<input type="text" name="middlename" placeholder="Middle Name" class="form-username form-control" id="form-username">
</div>
<div class="form-group">
<label class="sr-only" for="form-username">Last Name:</label>
<input type="text" name="lastname" placeholder="Last Name" class="form-username form-control" id="form-username" required="">
</div>
<div class="form-group">
<label class="sr-only" for="form-username">Address:</label>
<input type="text" name="address" placeholder="Address" class="form-username form-control" id="form-username" required="">
</div>
<div class="form-group">
<label class="sr-only" for="form-username">Phone No:</label>
<input type="text" name="phoneno" placeholder="Phone No" class="form-username form-control" id="form-username" required="">
</div>
<div class="form-group">
<label class="sr-only" for="form-username">Email Id:</label>
<input type="email" name="email" placeholder="Email Id" class="form-username form-control" id="form-username" required="">
</div>
<div class="form-group">
<label class="sr-only" for="form-username">Password:</label>
<input type="password" name="password" placeholder="Password" class="form-username form-control" id="form-username" required="">
</div>
<button type="submit" name="submit" class="btn">Sign in!</button>
</form>
<?php include_once('config.php');
if(isset($_POST['submit'])) {
$firstname = $_POST['firstname'];
$middlename = $_POST['middlename'];
$lastname = $_POST['lastname'];
$address =$_POST['address'];
$phoneno = $_POST['phoneno'];
$email = $_POST['email'];
$password = $_POST['password'];
//query
$query ="INSERT INTO login(`id`, `first_name`, `middle_name`, `last_name`, `address`, `phone_no`, `email`, `password`) VALUES ('',$firstname','$middlename','$lastname','$address','$phoneno','$email','$password')";
$result = #mysqli_query($query,$link);
if (!$result) {
echo "Data is not Inserted"; //this statement show me all time when submitting the data
}else { echo "Data is Inserted Successful";}}?>
Can u help me what mistake i m doing.
There are several things you can do:
Remove # in front of myslqi_query to show the error message.
If you still see no error message, then make sure that errors will get reported. See display-errors and error_reporting().
Do echo $query right after it is defined. If the query looks right, then copy it, and try running it against your database, using a MySQL client, such as HeidiSQL, or mysql command line.
Correct your english. Do not use "SMS english". It will encourage people to help you.

My HTML form only returns 1 value into the PHP mail

The email I receive only shows the message, not the email address or phone number or even the name.
It also doesn't show from which email it has been sent.
I should receive whole information from the form, otherwise it wouldn't show me the message, I guess.
Maybe someone has more simple code than this one?
I tried but I'm stuck.
Can someone help me out?
Below is the HTML and PHP code
HTML Code:
<form name="mail" action="mail.php" method="post" >
<div class="form-group ">
<input id="name" class="form-control" placeholder="Name" type="text" required>
<label for="name" class="sr-only">Name</label>
</div>
<div class="form-group ">
<label for="email" class="sr-only">Email</label>
<input id="email" class="form-control" placeholder="Email" type="email" required>
</div>
<div class="form-group ">
<label for="phone" class="sr-only">Phone</label>
<input id="phone" class="form-control" placeholder="Phone" type="text" required>
</div>
<div class="form-group ">
<label for="message" class="sr-only">Message</label>
<textarea name="message" id="message" cols="30" rows="5" class="form-control" placeholder="Message" required></textarea>
</div>
<div class="form-group ">
<input class="btn btn-primary btn-lg" value="Send Message" name="submit" type="submit">
</div>
</div>
</form>
PHP code:
<?php
if(!isset($_POST['submit']))
{
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
}
$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
$email_from = "$email";//<== update the email address
$email_subject = "New Form submission";
$email_phone = $phone;
$email_body = "You have received a new message from the user ".$name.
"\nHere is the message:\n ".$message.
"\nThe phone number:\n ".$phone.
"The email:\n ".$email.
$to = "info#czwebdesign.be";//<== update the email address
$headers = "From: $email_from \r\n";
$headers .= "Reply-To: $email \r\n";
//Send the email!
mail($to,$email_subject,$email_body,$headers);
//done. redirect to thank-you page.
header('Location: index.html');
?>
You also need to use name attribute for other fields as well same like message field, something like:
<input name="email" class="form-control" placeholder="Email" required>
<input name="name" class="form-control" placeholder="NAme" required>
<input name="phone" class="form-control" placeholder="Phone" required>
Otherwise you will get the Undefined Index warning in your script.
It's better to use php error_reporting() in your development mode, this will help to find out all errors and warnings in your code.
// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);
// Report all PHP errors (see changelog)
error_reporting(E_ALL);
Try this
<form name="mail" action="mail.php" method="post" >
<div class="form-group ">
<input id="name" class="form-control" placeholder="Name" type="text" name="name" required>
<label for="name" class="sr-only">Name</label>
</div>
<div class="form-group ">
<label for="email" class="sr-only">Email</label>
<input id="email" name="email" class="form-control" placeholder="Email" type="email" required>
</div>
<div class="form-group ">
<label for="phone" class="sr-only">Phone</label>
<input id="phone" name="phone" class="form-control" placeholder="Phone" type="text" required>
</div>
<div class="form-group ">
<label for="message" class="sr-only">Message</label>
<textarea name="message" id="message" cols="30" rows="5" class="form-control" placeholder="Message" required></textarea>
</div>
<div class="form-group ">
<input class="btn btn-primary btn-lg" value="Send Message" name="submit" type="submit">
</div>
</div>
</form>
Look here at the missing name="" attribute in your <input>
Use this code instead:
<form name="mail" action="mail.php" method="post" >
<div class="form-group ">
<input name="name" id="name" class="form-control" placeholder="Name" type="text" required>
<label for="name" class="sr-only">Name</label>
</div>
<div class="form-group ">
<label for="email" class="sr-only">Email</label>
<input name="email" id="email" class="form-control" placeholder="Email" type="email" required>
</div>
<div class="form-group ">
<label for="phone" class="sr-only">Phone</label>
<input name="phone" id="phone" class="form-control" placeholder="Phone" type="text" required>
</div>
<div class="form-group ">
<label for="message" class="sr-only">Message</label>
<textarea name="message" id="message" cols="30" rows="5" class="form-control" placeholder="Message" required></textarea>
</div>
<div class="form-group ">
<input class="btn btn-primary btn-lg" value="Send Message" name="submit" type="submit">
</div>
</div>
</form>

php post not working as expected

I have a form with 3 input fields , the below field is not working as expected , post data is not being posted , remaining two input fields are working correctly
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php?m=std">
<div class="row contact-wrap">
<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php?m=std">
<div class="col-sm-10 col-sm-offset-1">
<div class="form-group">
<label>Name *</label>
<input type="text" name="name" class="form-control" required="required">
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" name="email" class="form-control" required="required">
</div>
</div>
<div class="col-sm-5 col-sm-offset-1">
<h4>Doing graduation</h4>
<div class="form-group">
<label>Name of college</label>
<input type="text" name="dngclgname" class="form-control" >
</div>
<div class="form-group">
<label>Place </label>
<input type="text" name="dngclgplace" class="form-control">
</div>
<div class="form-group">
<label>Completing in</label>
<input type="text" name="dngcomp" class="form-control">
</div>
</div>
<div class="col-sm-5 col-sm-offset-1">
<h4>Completed Graduation</h4>
<div class="form-group">
<label>Name of college</label>
<input type="text" name="clgname" class="form-control" >
</div>
<div class="form-group">
<label>Place </label>
<input type="text" name="clgplace" class="form-control">
</div>
<div class="form-group">
<label>Year of completion</label>
<input type="text" name="comp" class="form-control">
</div>
</div>
<div class="col-sm-5 col-sm-offset-1">
<h4>Post Graduation</h4>
<div class="form-group">
<label>Name of college</label>
<input type="text" name="pgclgname" class="form-control" >
</div>
<div class="form-group">
<label>Place </label>
<input type="text" name="pgclgplace" class="form-control">
</div>
<div class="form-group">
<label>Year of completion</label>
<input type="text" name="pgcomp" class="form-control">
</div>
</div>
<div class="col-sm-5 col-sm-offset-1">
<h4>Working</h4>
<div class="form-group">
<label>Name of Company</label>
<input type="text" name="companyname" class="form-control" >
</div>
<div class="form-group">
<label>Place </label>
<input type="text" name="companyplace" class="form-control">
</div>
<div class="form-group">
<label>Working since</label>
<input type="text" name="companywrk" class="form-control">
</div>
<div class="form-group">
<label>Total no of years of experience</label>
<input type="text" name="companyexp" class="form-control">
</div>
</div>
<div class="col-sm-10 col-sm-offset-1">
<div class="form-group">
<label>Subject *</label>
<input type="text" name="subject" class="form-control" required="required">
</div>
<div class="form-group">
<label>Your Message/ Query/ Information required *</label>
<textarea name="message" id="message" required="required" class="form-control" rows="8"></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button>
</div>
</div>
</form>
</div><!--/.row-->
this is a part of my php code
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for contacting us. As early as possible we will contact you '
);
// some code here (if condition, check if user has input other form , if user input this form everything is fine)
elseif($m == 'std'){
$name = trim(stripslashes($_POST['name']));
$email = trim(stripslashes($_POST['email']));
$subject = trim(stripslashes($_POST['subject']));
$message = trim(stripslashes($_POST['message']));
$dngclgname = trim(stripslashes($_POST['dngclgname']));
$dngclgplace = trim(stripslashes($_POST['dngclgplace']));
$dngcomp = trim(stripslashes($_POST['dngcomp']));
$clgname = trim(stripslashes($_POST['clgname']));
$clgplace = trim(stripslashes($_POST['clgplace']));
$comp = trim(stripslashes($_POST['comp']));
$pgclgname = trim(stripslashes($_POST['pgclgname']));
$pgclgplace = trim(stripslashes($_POST['pgclgplace']));
$pgcomp = trim(stripslashes($_POST['pgcomp']));
$companyname = trim(stripslashes($_POST['companyname']));
$companyplace = trim(stripslashes($_POST['companyplace']));
$companywrk = trim(stripslashes($_POST['companywrk']));
$companyexp = trim(stripslashes($_POST['companyexp']));
$email_from = $email;
$email_to = 'my email address';//replace with your email
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'graduating college name: ' . $dngclgname . "\n\n" . 'graduating college Place: ' . $dngclgplace . "\n\n" . 'graduation completion year: ' . $dngcomp . "\n\n" . ' graduated College name: ' . $clgname . "\n\n" . ' graduated College Place: ' . $clgplace . "\n\n" . ' Graduated Year: ' . $comp . "\n\n" . 'Post Graduation College name: ' . $pgclgname . "\n\n" . 'Post Graduation College Place: ' . $pgclgplace . "\n\n" . 'Post Graduation Completion/completed year: ' . $pgcomp . "\n\n" . 'Company name: ' . $companyname . "\n\n" . ' Company place: ' . $companyplace . "\n\n" . 'Working since : ' . $companywrk . "\n\n" . 'Total no of years of experience : ' . $companyexp . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = #mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
}
When i click on submit am getting redirecting to the correct url and even mail is coming to my address but all the user input fiels are empty in the mail , even from address in the mail is also empty ,
You should debug your code with var_dump($_POST).
You will see if all input value works.
When i've tried your code, everything worked well.

PHP contact form not working right

I've been working on a contact form. I have added used the POST method to send it to a set email address. It doesn't seem to be working though. It just runs and stops as if the code is broken. The HTML and PHP are below.
<form action="contact-form.php" method="post" id="contact-form" name="contact-form">
<div class="form-group">
<label for="name">Your name</label> <input class=
"form-control" id="name" name="name" type="text">
</div>
<div class="form-group">
<label for="email">Email address</label>
<input class="form-control" id="email" name="email"
type="email">
</div>
<div class="form-group">
<label for="phone">Phone</label> <input class=
"form-control" id="phone" name="phone" type="text">
</div>
<div class="form-group">
<label for="message">Your message</label>
<textarea class="form-control" id="message" name=
"message" rows="6">
</textarea>
</div>
<div class="submit">
<input class="button button-small" type="submit"
value="Send">
</div>
</form>
<?php
if(isset($_POST['submit'])) {
$to = "gfrazer#hotmail.co.uk";
$from = $_POST['email'];
$name = $_POST['name'];
$phone = $_POST['phone'];
$message = $name . " " . " wrote the following: " . "\n\n" . $_POST['message'];
$headers = "From:" . $from;
$headers2 = "From:" . $to;
mail($to,$subject,$message,$headers);
mail($from,$subject2,$message2,$headers2); // sends a copy of the message to the sender
header('Location: http://www.google.co.uk');
}
?>
You need to add a name to your submit button. From your snippit, you have no $_POST['submit']:
<form action="contact-form.php" method="post" id="contact-form" name="contact-form">
<div class="form-group">
<label for="email">Email address</label>
<input class="form-control" id="email" name="email" type="email">
</div>
<div class="form-group">
<label for="phone">Phone</label> <input class="form-control" id="phone" name="phone" type="text">
</div>
<div class="form-group">
<label for="message">Your message</label>
<textarea class="form-control" id="message" name="message" rows="6"></textarea>
</div>
<div class="submit">
<!-- ADD name="submit" -->
<input name="submit" class="button button-small" type="submit" value="Send" />
</div>
</form>

Contact form sends email but without user inputs

This bootstrap using html/php contact form sends me an email just fine, but without any of the users input information!
The email I received looks empty like this:
Name:
Email:
Subject:
Message:
The html for the form is:
<section id="partner">
<div class="container">
<div class="center wow fadeInDown">
<h2><br>Contact</h2>
<p class="lead">Send a general enquiry here or order your service here.</p>
</div>
<div class="row contact-wrap">
<div class="status alert alert-success" style="display: none"></div>
<form id="main-contact-form" class="contact-form" name="contact-form" method="post" action="sendemail.php">
<div class="col-sm-5 col-sm-offset-1">
<div class="form-group">
<label>Name *</label>
<input type="text" name="name" class="form-control" required="required">
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" name="email" class="form-control" required="required">
</div>
<div class="form-group">
<label>Phone</label>
<input type="number" class="form-control">
</div>
<div class="form-group">
<label>Company Name</label>
<input type="text" class="form-control">
</div>
</div>
<div class="col-sm-5">
<div class="form-group">
<label>Subject *</label>
<input type="text" name="subject" class="form-control" required="required">
</div>
<div class="form-group">
<label>Message *</label>
<textarea name="message" id="message" required="required" class="form-control" rows="8"></textarea>
</div>
<div class="form-group">
<button type="submit" name="submit" class="btn btn-primary btn-lg" required="required">Submit Message</button>
</div>
</div>
</form>
</div><!--/.row-->
</div><!--/.container-->
</section><!--/#contact-page-->
The PHP for the form looks like this:
<?php
header('Content-type: application/json');
$status = array(
'type'=>'success',
'message'=>'Thank you for contact us. As early as possible we will contact you '
);
$name = #trim(stripslashes($_POST['name']));
$email = #trim(stripslashes($_POST['email']));
$subject = #trim(stripslashes($_POST['subject']));
$message = #trim(stripslashes($_POST['message']));
$email_from = $email;
$email_to = 'heerschapnikki#gmail.com';//replace with your email
$body = 'Name: ' . $name . "\n\n" . 'Email: ' . $email . "\n\n" . 'Subject: ' . $subject . "\n\n" . 'Message: ' . $message;
$success = #mail($email_to, $subject, $body, 'From: <'.$email_from.'>');
echo json_encode($status);
die;
Why isn't it working properly? The message "thank you for contacting us" pops up fine and the email sends through, but non of the users information comes through.
Try to print the values you are sending. So use this:
var_dump( $_POST['name'] );
var_dump( $_POST['email'] );
etc...
Doing this, you will be able to see wether your fields are even posted correctly.
the fields have no id param. in the post you get the "id" nor the "name"
<label>Name *</label>
<input type="text" id="name" class="form-control" required="required">
</div>
<div class="form-group">
<label>Email *</label>
<input type="email" id="email" class="form-control" required="required">

Categories