Commit 5800c3f7 by Visgha Olivia

Upload New File

parent f6b9c383
<?php
require_once 'common/database.php';
if(!isset($_SESSION['logged_in'])){
header('location: index.php');
}
$id = $_POST['id'];
$nama = $_POST['nama'];
$deskripsi = $_POST['deskripsi'];
$tanggal = $_POST['tanggal'];
$harga = $_POST['harga'];
$kuota = $_POST['kuota'];
if(isset($_POST['edit_photo'])){
$gambar = $_FILES['gambar']['name'];
$tmp = $_FILES['gambar']['tmp_name'];
$gambar_baru = date('dmYHis').$gambar;
$path = "uploads/".$gambar;
if(move_uploaded_file($tmp,$path)){
$datapaket = getOnePaket($_POST['id']);
$hasil = mysqli_fetch_array($datapaket,MYSQLI_ASSOC);
if(is_file("uploads/".$hasil['gambar']))
unlink("uploads/".$hasil['gambar']);
$do = EditPaket($id,$nama,$deskripsi,$tanggal,$gambar,$harga,$kuota);
if($do){
echo "<script>alert('Paket $nama telah diubah');
window.location = 'paket.php'</script>";
}
else{
echo "<script>alert('Paket $nama gagal diubah');
window.location = 'paket.php#edit_.'.$id'</script>";
}
}
else{
echo "Maaf, gambar gagal diupload.";
redirect('paket.php#edit_'.$id);
}
}
else{
$query = "UPDATE paket SET nama_paket='$nama',deskripsi='$deskripsi',
tanggal='$tanggal',harga='$harga',kuota='$kuota'
WHERE id_paket='$id'";
if(ExecuteQuery($query)){
echo "<script>alert('Paket $nama telah diubah');
window.location = 'paket.php'</script>";
}
else {
echo "<script>alert('Paket $nama gagal diubah');
window.location = 'paket.php#edit_.'.$id'</script>";
}
}
?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment