<?php

	/* Grab the URL variable */
	$Seed = $_GET["Seed"];
	$doy = $_GET["doy"];
	$acode = $_GET["acode"];
	
	/* Connect to database and grab the keys */
		
	mysql_connect("localhost","u9cwxhx7pzvxt","Maggie@2014SG$2014%%")
	or die("Couldnt connect to database server");
	mysql_selectdb("phibase0_iphft")
	or die("Couldnt select database");
		
	$query = "SELECT `Account_1` FROM `subscription`  WHERE Acode='{$acode}'";
		
	$result = mysql_query($query);
	$num=mysql_numrows($result);

	/* Set up a loop to check if requested key is found in database */
	$i=0;
	$validationkey = 0;

	$validation = "";


	if ($result=mysql_query($query))
	{
		while ($obj=mysql_fetch_array($result))
		{
			if ($Seed == $obj->Account_1)
			{
				$validation = "Okay";
			}	
		}
		mysql_free_result($result);
	}	
		

	
	//If a match was found in database, echo "VALID". Else echo "ERROR" 
	if($validation != "") {
		echo ($Seed  % 961) + 96  ;
	} else {
		echo 111111;
	}


?>