Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "koneksi.php";
- session_start();
- $username=$_SESSION['username'];
- $jumlah=$_POST['jumlah'];
- $id=$_POST['id'];
- $query_cek="SELECT * FROM detail where id_produk='$id' AND username='$username' AND proses='cart'";
- $hasil_cek=mysqli_query($koneksi,$query_cek);
- $hasil_cek1=mysqli_query($koneksi,$query_cek);
- $data=mysqli_fetch_array($hasil_cek1);
- $cek=mysqli_num_rows($hasil_cek);
- if ($cek==0) {
- $query="INSERT INTO detail VALUES('','','$jumlah','$id','$username','cart')";
- $hasil=mysqli_query($koneksi,$query);
- if ($hasil) {
- header('location:cart.php');
- } else {
- echo "Gagal beli";
- }
- }else{
- $qty=$data['qty']+$jumlah;
- $query_update="UPDATE detail set qty='$qty' WHERE id_produk='$id' AND username='$username'";
- $hasil_update=mysqli_query($koneksi,$query_update);
- if ($hasil_update) {
- header('location:cart.php');
- } else {
- echo "Gagal beli";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement