


<?php
	$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');
	
	mysql_selectDB("wauhaha_karaoke",$login);

	$StaffID=$_GET['StaffID'];
	
	$position = $_POST["position"];

$result3 = mysql_query("SELECT * from salaryrate where position='$position'");
	
if($row2 = mysql_fetch_array($result3)){
$basic = $row2['basic'];	
$overtime = $row2['overtime'];
$epfrate = $row2['epfrate'];
$ccc = $row2['cepf'];
 } 
 $epf=$basic * $epfrate;
  $result =$basic - $epf;
 
$epf1=$basic * $ccc;
 
 
$query1=mysql_query("INSERT INTO salary(StaffID, Salary,position, Epf, TSalary,epf1) VALUES('$StaffID','$basic','$position','$epf','$result','$epf1')");

if($query1){

	echo "<script language=javascript>alert('Arrange successful!!');window.location='http://www.wauhaha.com/karaoke/salary.php'</script>";
}
echo "<script language=javascript>alert('Update fail!!');window.location='http://www.wauhaha.com/karaoke/salary.php'</script>";




	
	?>