<?php
session_start();
$username = $_SESSION['staff'];
if($_SESSION['staff']!= null)
{
include("connect.php");

$memberName = $_POST['memberName'];
$giftpoint = $_POST['giftpoint'];
$pointbalance = $_POST['pointbalance'];

	$result = mysql_query("SELECT * FROM gift WHERE redeempoint = '$giftpoint'");
	$row = mysql_fetch_array($result);

	$giftquantity = $row['giftquantity'];
	$newquantity = $giftquantity - 1;
	
	$result5 = mysql_query("UPDATE membership SET memberpoint = '$pointbalance' WHERE memberLname = '$memberName'");

	$result2 = mysql_query("UPDATE gift SET giftquantity = '$newquantity' WHERE redeempoint = '$giftpoint'");
	
	$db = mysql_close();
	//echo "<script language='javascript'>alert('$j')</script>";
	echo "<script language='javascript'>window.location='cashiermain.php'</script>";
}
?>