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>
<div>
<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"
placeholder="Last">
</div>
<!-- other input fields here -->
<div class="submit">
<input type="submit" name="submit" class="submit_btn" value="Submit">
</div>
</form>


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



<?php
mysqli_connect("localhost:3308","root","9gUCFpWmzh");
mysqli_select_db("personal_info");
if(isset($_REQUEST['submit']))
{
$errorMessage = "";
$Firstname=$_POST['Firstname'];
$Lastname=$_POST['Lastname'];
// other variables and validation here
if ($errorMessage != "" ) {
echo "<p class='message'>" .$errorMessage. "</p>" ;
}
else{
//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')";
mysqli_query($insertTB);
}
}
?>


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







http://ift.tt/1rt24zQ