<?php
include 'conn.php';
include 'funciones.php';

date_default_timezone_set("America/Panama");
session_start();

$_SESSION['database'] = $_GET['database'];
$_SESSION['numero'] = $_GET['numero'];
$_SESSION['monto'] = $_GET['monto'];

$hoynow = getdate();

 if ($_SESSION['monto']==""){
	$_SESSION['monto']="0";
}

$timeStamp= $hoynow["year"]."-".$hoynow["mon"]."-".$hoynow["mday"] ;

if ($_SESSION['numero']=="0"){
	echo "false";}
else{
	$SQLupdate= "UPDATE ".$_SESSION['database'].".gift_certificate SET gift_fechault='".$timeStamp."',gift_usado=gift_usado+".$_SESSION['monto']." WHERE gift_certificate.gift_number='".$_SESSION['numero']."' LIMIT 1 ";

	if (mysqli_query($connection, $SQLupdate) == TRUE) {
		echo "true";
	} else {
		echo "Error: " . $SQLupdate . "<br>" . $conn->error;
	}
}

@mysqli_close($connection);
?>
