Hello,
i need help here...., i try to insert my data into mysql, but every time when i insert data into my database, its insert two record in one time, 1 row is the data that i insert and another row is empty, just the auto increment column have filled, can someone help me??
this is my code for php and sql:
<?php
function date2mysql($year, $month, $day) {return checkdate($month, $day, $year) ? "$year-$month-$day" :false;}
$date = date2mysql($_POST['year'], $_POST['month'], $_POST['day']);
if (!$date) {$error = 'Invalid date';}
$con=mysqli_connect("localhost","hazuan","hazuan","e-maintenance");
// Check connection
if (mysqli_connect_errno()){echo "Failed to connect to MySQL: " . mysqli_connect_error();}
$sql="INSERT INTO aduan (Jenis_Aset, Keterangan_Aset, No_Siri_Pendaftaran, Pengguna_Terakhir, Tarikh_Kerosakan, Perihal_Kerosakan, Nama, Ic, Syor_Pegawai_Aset, Lokasi)VALUES('$_POST[Jenis]','$_POST[Keterangan]','$_POST[Pendaftaran]','$_POST[Pengguna]','$date','$_POST[Perihal]','$_POST[Nama]','$_POST[Ic]','$_POST[Bahagian]','$_POST[Lokasi2]')";
if (!mysqli_query($con,$sql)){die('Error: ' . mysqli_error($con));}
echo "1 record added";
mysqli_close($con);?>