alexa-tracking

Butuh PENCERAHAN urgen!

Main Content

1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/5b6eba8214088dbc0c8b4567/butuh-pencerahan-urgen
Butuh PENCERAHAN urgen!
newbie nih di sini gan, Saya lagi ngoding inih nih agan-agan, tapi saya ga tau lagi dimana kesalahan saya, udah cek berulang ulang.. mohon pencerahannya ya soalnya urgen bgt jadi ceritanya gini : pas saya tekan button checkout,  query insert ke db sudah ada tapi data ga masuk, saya udah sesuaikan dengan nama nama di db.


<?php
session_start();
//skrip koneksi
$koneksi=new mysqli("localhost","root","","e_kost");

//proteksi chart2 agar pencari kos yang login saja yang dapat mengakses
if (!ISSET($_SESSION["pencari kos"]))
{
echo "[removed]alert('Silahkan Login Dahulu');[removed]";
echo "[removed]location='loginp.php';[removed]";
}
?>
<!DOCTYPE html>
<html lang="en">

 <head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

<link rel="shortcut icon"  href="foto_kos/rr.png">
    <title> Pencarian dan Pemesanan Kos Kec.Tampan Pekanbaru  </title>


   <!-- Bootstrap core CSS -->
    <link href="cs/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom fonts for this template -->
    <link href="cs/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href='https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
    <link href='https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800' rel='stylesheet' type='text/css'>

    <!-- Custom styles for this template -->
    <link href="cs/css/clean-blog.min.css" rel="stylesheet">

</head>
<body>
<!-- navbar -->
<?php include 'menu.php';?>
<header > 
<img class="thumbnail" src= "foto_kos/hj6.jpg" width="335" height="120">
<img class="thumbnail" src= "foto_kos/hj.jpg" width="666" height="120">
<div class="overlay"></div>
<div class="container">
        </div>
      </div>
    </header>

<section class="konten">
<div class="container"><br>

<h5>Your Chart : | <?php echo $_SESSION["pencari kos"]['nama'];?> | 
<?php echo $_SESSION["pencari kos"]['telp'];?> 
<button class="btn-primary btn-sm pull-right" name="checkout"><i class="fa fa-check"></i> Checkout</button>
</h5>
<br>
<div class="row" align="center">
                <div class="col-md-12">
                    <!-- Advanced Tables -->
<div class="panel panel-primary">
                        <div class="panel-heading">
                             BOARDING HOUSE BOOKING 
                        </div>
                         <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table  table-striped table-hover" id="dataTables-example">
<thead>
<tr>
<th>No</th>
<th>Kos</th>
<th>Pemilik</th>
<th>Telepon</th>
<th>Kelurahan</th>
<th>Alamat</th>
<th>Harga</th>
<th>Foto</th>
<th>Book</th>
<th>Tagihan</th>

</tr>
</thead>
<tbody>

<?php $no=1; ?>
<?php $total=0; ?>
<?php foreach ($_SESSION["chart"] as $id_kos=> $jumlah): ?>
<!--tampilkan kos yang dibooking yang sudah diperulangkan bdds id kos-->
<?php $ambil=$koneksi->query("SELECT * FROM kos INNER JOIN user ON user.id_user=kos.id_user
INNER JOIN detail_kos ON detail_kos.id_kos=kos.id_kos INNER JOIN kelurahan ON kelurahan.id_kel=kos.id_kel where kos.id_kos='$id_kos'");
$pecah=$ambil->fetch_assoc(); 
$subharga=$pecah["harga_kos"]*$jumlah;
?>
<tr>
<td><?php echo $no; ?></td> 
<td><?php echo $pecah["nm_kos"];?></td>
<td><?php echo $pecah["nm_user"];?></td>
<td><?php echo $pecah["telp"];?></td>
<td><?php echo $pecah["nm_kel"];?></td>
<td><?php echo $pecah["alamat"];?></td>
<td>Rp. <?php echo number_format($pecah["harga_kos"]);?></td>
<td><img src="kos/<?php echo $pecah['gambar'];?>" width="100"></td>
<td><?php echo $jumlah;?></td>
<td>Rp. <?php echo number_format($subharga);?></td>
</tr>
<?php $no++; ?>
<?php $total+=$subharga; ?>
<?php endforeach ?>

</tbody>
<tfoot>
<tr>
<th colspan="9" >Total Tagihan Anda : </th>
<th> Rp. <?php echo number_format($total) ?></th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</section>



<?php
if (ISSET($_POST["checkout"]))
{
$iduser = $_SESSION["pencari kos"]["id_user"];
$kos = $_POST["$id_kos"];
$tglbook = date("Y-m-d");
$tagihan = $_POST["$total"];

//menyimpan bookingan
$koneksi->query("INSERT INTO booking (id_user,tgl_book,total_tagihan) 
VALUES('$iduser','$tglbook','$tagihan') ");

//simpan detail booking
$id_bookingbaru=$koneksi->insert_id;
foreach ($_SESSION["chart"] as $id_kos => $jumlah)
{
$koneksi->query("INSERT INTO detail_booking(id_detailbook,id_book,id_kos,jumlah)
VALUES('','$id_bookingbaru','$id_kos','$jumlah')");
}
//kosongkan chart booking sementara
unset($_SESSION["chart"]);

//alihkan tampilan ke Nota BOOKING
echo "[removed] alert('Booking Kos Sukses');[removed]";
echo "[removed]location='reservasi.php?id=$id_bookingbaru';[removed]";

}
?> 



<hr>
  <!-- Footer -->
    <footer>
      <div class="container">
        <div class="row">
          <div class="col-lg-8 col-md-10 mx-auto">
            <ul class="list-inline text-center">
              <li class="list-inline-item">
                <a href="#">
                  <span class="fa-stack fa-lg">
                    <i class="fa fa-circle fa-stack-2x"></i>
                    <i class="fa fa-whatsapp fa-stack-1x fa-inverse"></i>
                  </span>
                </a>
              </li>
              <li class="list-inline-item">
                <a href="#">
                  <span class="fa-stack fa-lg">
                    <i class="fa fa-circle fa-stack-2x"></i>
                    <i class="fa fa-facebook fa-stack-1x fa-inverse"></i>
                  </span>
                </a>
              </li>
              <li class="list-inline-item">
                <a href="#">
                  <span class="fa-stack fa-lg">
                    <i class="fa fa-circle fa-stack-2x"></i>
                    <i class="fa fa-instagram fa-stack-1x fa-inverse"></i>
                  </span>
                </a>
              </li>
            </ul>
            <p class="copyright text-muted">Copyright © iKOS 2018</p>
          </div>
        </div>
      </div>
    </footer>

      <!-- Bootstrap core JavaScript -->
    [removed][removed]
    [removed][removed]

    <!-- Custom scripts for this template -->
    [removed][removed]
</body>
</html>


Quote:

Code:
//menyimpan bookingan
$hasil = $koneksi->query("INSERT INTO booking (id_user,tgl_book,total_tagihan)
VALUES('$iduser','$tglbook','$tagihan') ");
if($hasil){
echo "berhasil<br>";
}else{
echo "gagal<br>";
}

×