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

$table		="admins";
$user		=str_replace("'","\'",$_POST[user]);
$pwd		=md5($_POST[pwd1]);
$nama	=str_replace("'","\'",$_POST[nama]);
$level		=$_POST[level];

$sql = mysql_query("SELECT username,password,nama_lengkap,level FROM $table WHERE username= '$user'");
$row = mysql_num_rows($sql);
if ($row>0){
	mysql_query("UPDATE $table SET password='$pwd',nama_lengkap='$nama',level='$level',lastupdate=now() WHERE username= '$user'");
	echo "Data sukses diubah.";
}
else{
	mysql_query("INSERT INTO $table (username,password,nama_lengkap,level) VALUES('$user','$pwd','$nama','$level')");
	echo "Data sukses disimpan";
}
?>