<?php

include  "../koneksi/koneksi.php";

$id = $_POST['id'];
$id_user = $_POST['id_user'];
$nama_aplikasi = $_POST['nama_aplikasi'];
$nama_perusahaan = $_POST['nama_perusahaan'];
$alamat = $_POST['alamat'];
$telepon = $_POST['telepon'];
$header = $_POST['header'];
$footer = $_POST['footer'];
$text_header = $_POST['text_header'];
$text_isi = $_POST['text_isi'];
$text_footer = $_POST['text_footer'];
$jam = $_POST['jam'];
$saran = $_POST['saran'];

$sp = $_POST['sp'];
$p = $_POST['p'];
$c = $_POST['c'];
$k = $_POST['k'];
$tp = $_POST['tp'];

$slideshow = $_POST['slideshow'];
$logo =  "file_".date("YmdHis").".". basename( $_FILES['logo']['name']); //ubah nama file
$background =  "file_".date("YmdHis").".". basename( $_FILES['background']['name']); //ubah nama file
$slide1 =  "file_".date("YmdHis").".". basename( $_FILES['slide1']['name']); //ubah nama file
$slide2 =  "file_".date("YmdHis").".". basename( $_FILES['slide2']['name']); //ubah nama file
$slide3 =  "file_".date("YmdHis").".". basename( $_FILES['slide3']['name']); //ubah nama file



if(!empty($_FILES['logo']['name']) || !empty($_FILES['background']['name']) || !empty($_FILES['slide1']['name']) || !empty($_FILES['slide2']['name']) || !empty($_FILES['slide3']['name'])){
 //--------------------------------logo ----------------------------
$target1 = "../images/$logo"; //Tempat file
 move_uploaded_file($_FILES['logo']['tmp_name'], $target1);
 
//--------------------------------background ----------------------------
$target2 = "../images/$background"; //Tempat file
move_uploaded_file($_FILES['background']['tmp_name'], $target2);

//--------------------------------Slide 1 ----------------------------
$target3 = "../images/$slide1"; //Tempat file
move_uploaded_file($_FILES['slide1']['tmp_name'], $target3);

//--------------------------------Slide 2 ----------------------------
$target4 = "../images/$slide2"; //Tempat file
move_uploaded_file($_FILES['slide2']['tmp_name'], $target4);

//--------------------------------Slide 3 ----------------------------
$target5 = "../images/$slide3"; //Tempat file
move_uploaded_file($_FILES['slide3']['tmp_name'], $target5);

$sql = "UPDATE aplikasi set nama_aplikasi='$nama_aplikasi', alamat='$alamat', telepon='$telepon', logo='$logo', background='$background', slide1='$slide1', slide2='$slide2', slide3='$slide3', nama_perusahaan='$nama_perusahaan', header='$header', footer='$footer', jam='$jam' , text_header='$text_header', text_isi='$text_isi', text_footer='$text_footer', saran='$saran',  slideshow='$slideshow', sp='$sp', p='$p', c='$c', k='$k', tp='$tp' WHERE id='$id'";
} else {
$sql = "UPDATE aplikasi set nama_aplikasi='$nama_aplikasi', alamat='$alamat', telepon='$telepon', nama_perusahaan='$nama_perusahaan', header='$header', footer='$footer', jam='$jam', text_header='$text_header', text_isi='$text_isi', text_footer='$text_footer', saran='$saran',  slideshow='$slideshow', sp='$sp', p='$p', c='$c', k='$k', tp='$tp'   WHERE id='$id'";
} 


$proses = mysql_query($sql);
	if ($proses) {
		header('location:../setting.php?sukses='.base64_encode("Halaman Front End telah berhasil diupdate").'');
	} else { echo "Data belum dapat di simpan!!"; 
	}
?>

