<?php
include "../../inc/inc.koneksi.php";

$table	 ="admins";
$user	 =$_POST['user'];
$kodecab =$_POST['kodecab'];
$pwd	 =md5($_POST['pwd1']);
$nama	 =$_POST['nama'];
$level	 =$_POST['level'];
$status	 =$_POST['status'];
$jamawal =$_POST['jamawal'];
$jamakhir=$_POST['jamakhir'];

$sql = mysql_query("SELECT * FROM $table WHERE username='$user'");
$row = mysql_num_rows($sql);
if ($row>0){
	mysql_query("UPDATE $table SET kode_cab='$kodecab',password='$pwd',nama_lengkap='$nama',level='$level',status='$status',jam_awal='$jamawal',jam_akhir='$jamakhir',lastupdate=now() WHERE username= '$user'");
	echo "Data Sukses diubah, begitu juga dengan Password Anda.";
}
else{
	mysql_query("INSERT INTO $table (username,kode_cab,password,nama_lengkap,level,status,jam_awal,jam_akhir) VALUES('$user','$kodecab','$pwd','$nama','$level','$status','$jamawal','$jamakhir')");
	echo "Data sukses disimpan";
}
?>