Form data not inserted into mySQL table

Friday, July 4, 2014

I have tried everything I can think of but the data from my form do not get inserted in the MySQL table. This is relevant part of my form:

<form id="masteringhtml5_form" action="send_formdata.php" method="POST">
<label for="heading" class="heading">Health Survey Form</label>
<fieldset class="fieldset_border">
<legend class="legend">Personal Information</legend>
<label for="name">Name</label><br>
<input type="text" name="Firstname" class="name txtinput"
placeholder="First" autofocus>
<input type="text" name="Lastname" class="name txtinput"
<!-- other input fields here -->
<div class="submit">
<input type="submit" name="submit" class="submit_btn" value="Submit">

And this is relevant part of my php file "send_formdata.php":

$errorMessage = "";
// other variables and validation here
if ($errorMessage != "" ) {
echo "<p class='message'>" .$errorMessage. "</p>" ;
//Inserting record in table using INSERT query
$insertTB="INSERT INTO `personal_info`.`personal`
(`Firstname`, `Lastname`, `Dob`, `Gender`, `Saddress`,
`Aaddress`, `City`, `State`, `Pincode`, `Country`, `Home`,
`Work`, `Email`) VALUES ('$Firstname', '$Lastname', '$Dob',
'$Gender', '$Saddress', '$Aaddress', '$City', '$State',
'$Pincode', '$Country', '$Home', '$Work', '$Email')";

The database and table are correct. I have run the script with "echo $insertTB" and that produces a full query statement in the browser.