I'm new to php and jQuery and I'm trying to get my form to work. I've coded the HTML for the form and next I want to sort the code for PHP and validate it. Below is the HTML and PHP code I have so far for the first part of the form...
When I test this out by filling in the fields and clicking send the only fields I receive in my email are firstName_field, lastName_field, street_field and lineTwo_field.
The rest...town_field, city_field and postcode_field are all empty in my sent email...does anyone know WHY????
// PHP CODE BELOW //
<?php
if(isset($_POST['submit'])) {
$to = "Email address goes here";
$subject = "Title";
// data the visitor provided
$firstName_field = filter_var($_POST['firstName'], FILTER_SANITIZE_STRING);
$lastName_field = filter_var($_POST['lastName'], FILTER_SANITIZE_STRING);
$street_field = filter_var($_POST['street'], FILTER_SANITIZE_STRING);
$lineTwo_field = filter_var($_POST['lineTwo'], FILTER_SANITIZE_STRING);
$town_field = filter_var($_POST['town'], FILTER_SANITIZE_STRING);
$city_field = filter_var($_POST['city'], FILTER_SANITIZE_STRING);
$postcode_field = filter_var($_POST['postcode'], FILTER_SANITIZE_STRING);
//constructing the message
$body = " From: $firstName_field $lastName_field\n Street: $street_field\n Address line 2: $lineTwo_field\n Town: $town_field\n City: $city_field\n Postcode: $postcode_field\n";
// ...and away we go!
mail($to, $subject, $body);
// redirect to confirmation
header('Location: thanks.html');
} else {
// handle the error somehow
}
?>
// HTML CODE BELOW //
<div id="formContainer">
<form id="quoteRequest" method="post" action="quoteRequest.php">
<div class="formDescription">
<h2>Quote Request</h2>
<p>Please complete the form below to receive a free Limousine hire quote for your requirements. You can also get a quote by calling one of our Customer Services Team on ...</p>
</div>
<!--------------------SECTION BREAK-------------------->
<div class="section_break">
<h3>Personal Details</h3>
</div>
<!--------------------NAME FIELD-------------------->
<div class="row">
<div class="label">Name *</div>
<input type="text" id="firstName" name= "firstName" class="detail" value=""/>
<label class="context">First</label>
<input type="text" id="lastName" name= "lastName" class="detail" value=""/>
<label class="context">Last</label>
</div>
<!--------------------ADDRESS FIELD-------------------->
<div class="row">
<div class="label">Address *</div>
<input type="text" name="street" class="detail" value="">
<label class="context">Street Address</label>
</div>
<div class="row">
<input type="text" name="lineTwo" class="detail" value="">
<label class="context">Address Line 2</label>
</div>
<div class="row">
<input type="text" name="town" class="detail" value="">
<label class="context">Town</label>
</div>
<div class="row">
<input type="text" name="city" class="detail" value="">
<label class="context">City</label>
</div>
<div class="row">
<input type="text" name="postcode" class="detail" value="">
<label class="context">Postcode</label>
</div>
</form>
</div>
Help















