<?php

	$CreNum=$_GET['CreNum'];
	$BalCredit =$_POST['balcredit'];
	$val1 =$_POST["val1"];
$time_offset ="240"; 
$time_a = ($time_offset * 120);
$time = date(("F,j,Y, g:i a"),time() + $time_a);

	$login=mysql_connect('localhost', 'wauhaha_karaoke', 'cross123','wauhaha_karaoke');

	mysql_selectDB("wauhaha_karaoke",$login);
	$AddCreditD =$_POST['addcreditd'];
$result =mysql_query("select * from credittran where CreID='$CreID' ");	
if($row=mysql_fetch_array($result)){
$MemID = $row["MemID"];
$Username = $row["Username"];
$Name = $row["Name"];

}
	$query=mysql_query("UPDATE regmember SET Credit='$BalCredit' where MemID='$MemID' ");


$query2=mysql_query("INSERT INTO credittran(CreID,MemID,Username,Name,AddCredit,AddCreditD,EditedD,BalCredit)VALUE('$CreID','$MemID','$Username','$Name','$val1','$AddCreditD','$time','$BalCredit')");
if($query2){
	echo "<script language=javascript>alert('Update successful!!');window.location='http://www.wauhaha.com/karaoke/credit.php'</script>";
}
echo "<script language=javascript>alert('Update fail!!');window.location='http://www.wauhaha.com/karaoke/credit.php'</script>";
	
	?>