<?php
include "../koneksi.php";
if(isset($_REQUEST['aksi'])) $aksi = $_REQUEST['aksi'];
else $aksi="";

switch($aksi){
case "Ubah":
$id =$_POST['id_tamu'];
$nama	= $_POST['namatamu'];
$user	= $_POST['username'];
$pass	= $_POST['password'];
$alamat	= $_POST['alamat'];
$telepon= $_POST['telepon'];
$instansi	= $_POST['instansi'];
$email	= $_POST['email'];
$query	= "UPDATE tamu SET username = '$user', nama = '$nama', password = md5('$pass'), alamat = '$alamat', nama_instansi = '$instansi', telepon= '$telepon', email= '$email' WHERE id_tamu = '$id'";
$sql	= mysql_query($query);
	if($sql==true){
		echo "<script>alert('Data berhasil diubah')</script>";
	}else{
		echo "<script>alert('Data gagal diubah')</script>";
	}

break;
case "Hapus":
$id = $_GET['id'];

$query = mysql_query("DELETE FROM tamu WHERE id_tamu= '$id'");
if($query == true){
echo"<script>alert('Data berhasil dihapus')</script>";
} else{
echo "<script>alert('Data gagal dihapus')</script>";
}
break;
}
?>

<meta http-equiv='refresh' content='0;URL=pelanggan.php'>