Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. <?php
  2. include "koneksi.php";
  3. session_start();
  4. $username=$_SESSION['username'];
  5. $jumlah=$_POST['jumlah'];
  6. $id=$_POST['id'];
  7.  
  8. $query_cek="SELECT * FROM detail where id_produk='$id' AND username='$username' AND proses='cart'";
  9. $hasil_cek=mysqli_query($koneksi,$query_cek);
  10. $hasil_cek1=mysqli_query($koneksi,$query_cek);
  11. $data=mysqli_fetch_array($hasil_cek1);
  12. $cek=mysqli_num_rows($hasil_cek);
  13. if ($cek==0) {
  14. $query="INSERT INTO detail VALUES('','','$jumlah','$id','$username','cart')";
  15. $hasil=mysqli_query($koneksi,$query);
  16. if ($hasil) {
  17. header('location:cart.php');
  18. } else {
  19. echo "Gagal beli";
  20. }
  21. }else{
  22. $qty=$data['qty']+$jumlah;
  23. $query_update="UPDATE detail set qty='$qty' WHERE id_produk='$id' AND username='$username'";
  24. $hasil_update=mysqli_query($koneksi,$query_update);
  25. if ($hasil_update) {
  26. header('location:cart.php');
  27. } else {
  28. echo "Gagal beli";
  29. }
  30. }
  31.  
  32. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement