I am new to PHP and MySQL. I created a php form to save some data to the databse table. After submitting the form, it gives
"1 recorded added"
as specified in the php insert string. But after opening the table in phpmyadmin, it shows a new row added but no data in it..
The php form is:
<h2>Register Yourself</h2>
<form method="post" action="get-member.php">
<div>
<span><p>First Name:</p></span>
<span><input type="text" class="form-control" id="FirstName"></span>
</div>
<div>
<span>Last Name:</span>
<span><input type="text" class="form-control" id="LastName"></span>
</div>
<div>
<span>Father's Name: </span>
<span><input type="text" class="form-control" id="FatherName"></span>
</div>
<div>
<span>Mother's Name: </span>
<span><input type="text" class="form-control" id="MotherName"></span>
</div>
<div>
<span>Date of Birth: </span>
<span><input type="date" class="form-control" id="DOB"></span>
</div>
<div>
<span>Address: </span>
<span><input type="text" class="form-control" id="Address"></span>
</div>
<div>
<span>City: </span>
<span><input type="text" class="form-control" id="City"></span>
</div>
<div>
<span>District: </span>
<span><input type="text" class="form-control" id="District"></span>
</div>
<div>
<span>Postal Code: </span>
<span><input type="text" class="form-control" id="PostalCode"></span>
</div>
<div>
<span>Personal Mobile #:</span>
<span><input type="number" class="form-control" id="Pmobile"></span>
</div>
<div>
<span>Father's Contact #:</span>
<span><input type="number" class="form-control" id="Fmobile"></span>
</div>
<div>
<span>Mother's Contct #:</span>
<span><input type="number" class="form-control" id="Mmobile"></span>
</div>
<div>
<span>Home contact #:</span>
<span><input type="number" class="form-control" id="Hmobile"></span>
</div>
<div>
<span><input type="submit" value="Register"></span>
</div>
</form>
and the get-member.php file is:
<?php
//stablising connection
include("../database/connection.php");
//escape variables for security
$FirstName = mysqli_real_escape_string($con, $_POST['FirstName']);
$LastName = mysqli_real_escape_string($con, $_POST['LastName']);
$FatherName = mysqli_real_escape_string($con, $_POST['FatherName']);
$MotherName = mysqli_real_escape_string($con, $_POST['MotherName']);
$DOB = mysqli_real_escape_string($con, $_POST['DOB']);
$Address = mysqli_real_escape_string($con, $_POST['Address']);
$City = mysqli_real_escape_string($con, $_POST['City']);
$District = mysqli_real_escape_string($con, $_POST['District']);
$PostalCode = mysqli_real_escape_string($con, $_POST['PostalCode']);
$Pmobile = mysqli_real_escape_string($con, $_POST['Pmobile']);
$Fmobile = mysqli_real_escape_string($con, $_POST['Fmobile']);
$Mmobile = mysqli_real_escape_string($con, $_POST['Mmobile']);
$Hmobile = mysqli_real_escape_string($con, $_POST['Hmobile']);
$sql="INSERT INTO RUPmembers (FirstName, LastName, FatherName, MotherName, DOB, Address, City, District, PostalCode, Pmobile, Fmobile, Mmobile, Hmobile)
VALUES ('$FirstName','$LastName','$FatherName','$MotherName','$DOB','$Address','$City','$District','$PostalCode','$Pmobile','$Fmobile','$Mmobile','$Hmobile')";
if (!mysqli_query($con,$sql))
{
die ('Error:' . mysqli_error($con));
}
echo "1 Record addedd";
//closing connection
include("../database/close-connection.php");
?>
The phpmyadmin table after inserting 3 data(s):
[sorry it is requesting to gain 10 repo to be able to add image, but here is the link of the screenshot http://oi60.tinypic.com/n6rtyu.jpg ]