I've changes the coding like this:huh:
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name=test_input($_POST['name']);
$nokp=test_input($_POST['nokp']);
$homeadd=test_input($_POST['homeadd']);
$teleoff=test_input($_POST['teleoff']);
$restele=test_input($_POST['restele']);
$mobiletele=test_input($_POST['mobiletele']);
$position=test_input($_POST['position']);
$grade=test_input($_POST['gred']);
$serviceduration=test_input($_POST['serviceduration']);
}
$name=$_POST['name'];
$nokp=$_POST['nokp'];
$homeadd=$_POST['homeadd'];
$teleoff=$_POST['teleoff'];
$restele=$_POST['restele'];
$mobiletele=$_POST['mobiletele'];
$position=$_POST['position'];
$grade=$_POST['grade'];
$serviceduration=$_POST['serviceduration'];
$mohappt=$_POST['mohappt'];
$t_t = $_POST["mohappt"];
$hari=substr("$t_t",0,2); $bulan=substr("$t_t",3,2); $tahun=substr("$t_t",6,4);
$mohappt="$tahun"."-"."$bulan"."-"."$hari";
//$mohappt=$_POST['mohappt'];
$strSQL = "SELECT * FROM peribadi_details WHERE nokp = '".$nokp."'";
$objQuery = mysqli_query($conn,$strSQL) or die ("Error Query [".$strSQL."]");
$checkavailable = mysqli_fetch_array ($objQuery);
if($checkavailable==1) {
$stmt="update peribadi,peribadi_details set namapegawai='$name',nokp=$nokp,homeadd1='$homeadd',officephone='$teleoff',homephone='$restele',mobilephone='$mobiletele',position='$position',grade=$grade,serviceduration=$serviceduration,mohappointment='$mohappt' WHERE peribadi.nokp=peribadi_details.nokp AND peribadi.nokp='$nokp'";
$objQuery = mysqli_query($conn,$stmt) or die ("Error Query [".$stmt."]");
$Num_Rows = mysqli_num_rows($objQuery);
}
else {
$a = $_POST['name'];
$b = $_POST['nokp'];
$c = $_POST['homeadd'];
$d = $_POST['teleoff'];
$e = $_POST['restele'];
$f = $_POST['mobiletele'];
$g = $_POST['position'];
$h = $_POST['grade'];
$i = $_POST['serviceduration'];
$j = $_POST['mohappt'];
$strSQL = "insert into peribadi_details (name,nokp,homeadd1,officephone,homephone,mobilephone,position,grade,serviceduration,mohappointment) VALUES ($a,$b,$c,$d,$e,$f,$g,$h,$i,$j)";
$objQuery = mysqli_query($conn,$strSQL) or die ("Error Query [".$strSQL."]");
$Num_Rows = mysqli_num_rows($objQuery);
echo "New records created successfully";
}
}
and the error came out like this
Error Query [insert into peribadi_details (name,nokp,homeadd1,officephone,homephone,mobilephone,position,grade,serviceduration,mohappointment) VALUES (GURVINDERJEET KAUR A/P SARJIT SINGH,870828565466,selayang,06-303456,727363,0112332143,Consultant,,,21-09-2018)]