Hi,am new in php and appreciate your help in this matter....tried to save the record below into mysql database but couldn't.The field are blank and the Targetid field is always 0.Below is the coding...Please advise...Tqvm
<html>
<body>
<form action="progress1.php" method="post">
<p> Quantitative Progress: <input type="text" name="Quanprogress1"></p>
<p>Qualitative Progress: <input type="text" name="Qualprogress1"></p>
<p>Comment to support Progress: <input type="text" name="Comment1"></p>
<input type="text" id="Targetid" name="Targetid" value="" >
<input type="submit">
</form>
</body>
</html>
<?php
$con=mysqli_connect("mysql01.staff.curtin.edu.my","pqadb1user","pqa@csm","pqadb1");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
if (isset($_POST['submit'])) //&& ($_POST['submit'] == "Submit")){`
// escape variables for security
$Quanprogress1 = mysqli_real_escape_string($con, $_POST['Quanprogress1']);
$Qualprogress1 = mysqli_real_escape_string($con, $_POST['Qualprogress1']);
$Comment1 = mysqli_real_escape_string($con, $_POST['Comment1']);
$Targetid =0;
if (isset($_POST['Targetid'])) {
$Targetid = $_POST['Targetid'];
$sql="INSERT INTO progress (Quanprogress1, Qualprogress1,Comment1,Targetid)
VALUES ('$Quanprogress1', '$Qualprogress1', '$Comment1', '$Targetid')";
if (!mysqli_query($con,$sql)) {
die('Error: ' . mysqli_error($con));
}else{
echo "1 record added";
}}
}
mysqli_close($con);
?>