I can't insert date(even my whole form) to mySQL. Here's my code:
if($_SERVER["REQUEST_METHOD"]=="POST") { $con = mysqli_connect('localhost','root','','e-Laundrydb'); $tglPickup = $_POST['tglPickup']; $barang = $_POST['inputItems']; $waktuPickup = $_POST['waktuPickup']; $query_order = "INSERT INTO order(Barang,Tanggal_Pengambilan,Waktu_Pengambilan) VALUES('$barang','$tglPickup','$waktuPickup');"; $result = mysqli_query($con,$query_order); if($result == false) { echo "<script>alert('INSERT IS NOT SUCCESS');</script>"; } else { echo "<script>alert('INSERT SUCCESS');</script>"; } } I use input type="date" in my php. And here's my table in database: Table Order
I can't find where's the problem. i updated the code and follow like your suggestions but still get nothing :( here's the code again:
if($_SERVER["REQUEST_METHOD"]=="POST") { //include('config/koneksi.php'); $con = mysqli_connect('localhost','root','','e-laundryDB'); //INSERT KE TABLE ORDER $tglPickup = date('Y/m/d', strtotime($_POST['tglPickup'])); $barang = $_POST['inputItems']; $waktuPickup = $_POST['waktuPickup']; $query_order = "INSERT INTO 'order'(Barang,Tanggal_Pengambilan,Waktu_Pengambilan) VALUES('$barang','$tglPickup','$waktuPickup')"; $result = mysqli_query($con,$query_order); if($result == false) { echo "<script>alert('INSERT IS NOT SUCCESS');</script>"; } else { echo "<script>alert('INSERT SUCCESS');</script>"; } mysqli_close($con); }
$tglPickup