<?
require("config.inc");
$staffID = $_GET['staffID'];
$StaffName = $_POST['SName'];
$StaffID = $_POST['SID'];
$Password = $_POST['SPass'];
$Address = $_POST['SAddress'];
$Sex = $_POST['Ssex'];
$Birthday = $_POST['SBir'];
$Email = $_POST['SEmail'];
//echo "<script>alert('".$productType."');</script>";

$query_search = "select * from tbl_user where user_ID = '$StaffID'";
$query_exec = mysql_query($query_search) or die(mysql_error());
$rows = mysql_num_rows($query_exec);
$row = mysql_fetch_array($query_exec);
if($StaffName == ""){echo "<script>alert('Name blank');</script>";}
else if($StaffID == ""){echo "<script>alert('ID blank');</script>";}
else if($Password == ""){echo "<script>alert('Password blank');</script>";}
else if($Address == ""){echo "<script>alert('Address blank');</script>";}
else if($Sex == ""){echo "<script>alert('Sex blank');</script>";}
else if($Birthday == ""){echo "<script>alert('Birthday blank');</script>";}
else if($Email == ""){echo "<script>alert('Email blank');</script>";}
else{
		if($row['user_ID'] == $StaffID){
			
			echo "<script>alert('Staff ID exist');</script>";
			echo "<script>window.location='checkStaff.php';</script>";
		}
		else{
			$result = mysql_query("insert into tbl_user (user_ID,username,password,address,sex,birthday,email) value ('$StaffID','$StaffName','$Password','$Address','$Sex','$Birthday','$Email')");
		}
}
//$row = mysql_fetch_array($result);
if($result-->0){
echo "<script>alert('Insert Success');</script>";
echo "<script>window.location='checkStaff.php';</script>";
}
else{
echo "<script>alert('Fail to Insert');</script>";
echo "<script>window.location='checkStaff.php';</script>";}
?>