我無法將日期(甚至是我的整個表單)插入mySQL。這裏是我的代碼:如何從PHP插入日期到MySQL
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>";
}
}
我在PHP中使用input type="date"
。這裏是我在數據庫中的表格: Table Order
我找不到問題在哪裏。 我更新的代碼,並遵循喜歡你的建議,但仍然得到什麼:( 這裏又是代碼:
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);
}
進入的日期值是什麼?如果你使用日期功能創建了表格,它不會花費時間 –
對不起,我試圖指定我的問題。這裏我現在編輯它,謝謝。 –
是整個表單值未被插入的問題嗎?還是隻有日期沒有被插入? –