I am using the code below to insert the values from the form into the MySQL database, however after the code executes the MySQL tables displays NULL, NULL instead of the actual value.
I have checked to see whether the values have been correctly obtained from the GET function, and there is no problem in that either
<?php
$vac_name=$_GET['vac_name'];
$vac_comment=$_GET['vac_comment'];
echo $vac_name;
echo $vac_comment;
$con=mysql_connect("localhost","root","");
if($con==true){
echo "Connected to the database";
if(isset($_GET['vac_name'], $_GET['vac_comment'])){
mysql_select_db("attendance_db",$con);
$query = "insert into vacationtype values(LAST_INSERT_ID(),vac_name,vac_comment)";
$result=mysql_query($query,$con);
//$row=mysql_num_rows($result);
// if($row>0){
if($result==true){
echo "Successfully saved your message <br> We shall be in contact with you shortly";
}else{
echo mysql_error();
echo "Sorry the message was not saved <br> Please try again. Thank You";
} }
mysql_close($con);
}else{
echo "Cannot connect to the database";
}
?>
Use your query like this