<?
$host = "XXXX";
$db = "1833309_XXX";
$user = "1833309_XXX";
$pw = "XXXXX";
$con = mysql_connect($host,$user,$pw) or die(mysql_error());
mysql_select_db($db) or die(mysql_error());
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES 'utf8'");
$action = $_GET["Action"];
switch ($action)
{
case "FindCode":
$mail=$_GET["Mail"];
$id = $_GET["ID"];
$table = $_GET["Table"];
$code = $_GET["Code"];
//look up code
$q = mysql_query("SELECT * FROM table$table Where Code LIKE '%$code%' LIMIT 1");
$count = mysql_num_rows($q);
if ($count > 0) #if no match to email found in DB
{
$row = mysql_fetch_array($q);
$result = $row['Bitting'];
$res = mysql_query("Insert into history (email, regnr, transaction, date) VALUES ('$mail', $id, 'Looked up Code $code Table$table - Found', NOW())");
print json_encode($result);
}
else
{
$res = mysql_query("Insert into history (email, regnr, transaction, date) VALUES ('$mail', $id, 'Looked up Code $code Table$table - NOT Found', NOW())");
Print json_encode("Invalid Code");
}
break;
}
?>