<?php
require('includes/settings.php');
require('includes/mysql_connect.php');
require('includes/funcs.php');
$p_email = strtolower(sanitize($_REQUEST['email']));

// Check if given email exceeds user limit for code type
$check_code_sql = 'SELECT count(*) from '.$g_KioskTableName.' ktn
	where ktn.strEmail="' . $p_email . '" and ktn.intBonusCode = 0'
;

//echo "<p>$check_code_sql</p>";
$check_code_result = getFromDatabase($check_code_sql);
$check_fetch = mysqli_fetch_array($check_code_result);
$count =  $check_fetch[0];
if ($count > 0)
{
	echo "fail";
	exit();
}
echo "valid";


?>
