<?php
include 'fungsi.php';
global $total;
$id_pemesanan = $_GET['id'];
$query = mysqli_query($conn, "SELECT * FROM pemesanan INNER JOIN kamar ON pemesanan.id_kamar = kamar.id WHERE pemesanan.id = '$id_pemesanan'" );
while($row = mysqli_fetch_array($query)){
	$total = $total += ($row['jumlahpeserta'] * $row['harga']);
}
$bukti = $_FILES['gambar']['name'];

move_uploaded_file($_FILES['gambar']['tmp_name'], 'gambar/' .$bukti);

$action = mysqli_query($conn, "INSERT INTO pembayaran VALUES('', '$id_pemesanan', '$total', '$bukti', '')");

if(!$action){
	echo mysqli_error();
}
else{
	echo "<script>alert('berhasil');window.location.href='pembayaran.php';</script>";
}
?>