我有一个代码,可以将表单中的帖子数据插入数据库中,但是代码'mysqli_query()'无效,我该如何解决?
该连接在其他页面中仍然有效
if (isset($_POST['submit']) ) {
// proses insert ke tabel
$nama = $_POST['nama'];
$telepon = $_POST['telepon'];
$nik = $_POST['nik'];
$nopol = $_POST['nopol'];
$tglpinjam = $_POST['tglpinjam'];
$tglkembali = $_POST['tglkembali'];
$harga = $_POST['harga'];
$tgltransaksi = Date('Y-m-d');
//simpan dalam tabel
$sql = "INSERT INTO transaksi VALUES('','$nama','$telepon','$nik','$nopol','$tglpinjam','$tglkembali','$harga','$tgltransaksi','','')";
$hsl = mysqli_query($conn, $sql);
//update status mobil
if($hsl){
$sql=mysqli_query($conn, "UPDATE mobil SET tersedia='0' WHERE nopol='$nopol'");
echo '<meta http-equiv="Refresh" content="0; url=../../dashboard/transaksi/dashboard-transaksi-kembali.php">';
//header('Location: transaksi-kembali.php');
}else {
echo 'kok salah !';
}
}else {
$sql = mysqli_query($conn, "SELECT nopol,merek,warna FROM mobil WHERE tersedia='1'");
我希望输出重定向到另一个页面,但实际输出是'kok sala!'文字