<html>

<body bgcolor="#d9f2ef">

<?php

if(!isset($_POST[token]) || $_POST[token] =='' || $_POST[token] ==null){
				
	echo 'No Page Token! Not authorized.';
				
}else{
	$incomingSecretPost = $_POST[token];
}
	
	
$random_token = md5(uniqid(rand(), true));
	

$con = mysql_connect("localhost","ooffle_tsm_admin","tsm12345");

if (!$con)

  {

  die('Could not connect: ' . mysql_error());

  }

 

mysql_select_db("ooffle_tsmballoons", $con);
		//continue writing
		
		$sql2="INSERT INTO nametable (token,created_at)

			VALUES

			('$random_token',now())";



			if (!mysql_query($sql2,$con))

			  {

			  die('Error: ' . mysql_error());

			  }
		//echo "Record(s) added";
		//echo "<script type='text/javascript'>alert('Registration successful! Get ready for the game...');</script>";
		
		
		
		//header("Location: BalloonPop/index.php");
		//header( "refresh:0.1;url=BalloonPop/index.php" );
	
	
	
 


				//continue writing
//$result= mysql_query("SELECT COUNT(*) AS total FROM nametable WHERE token


		$getURLresult= mysql_query("SELECT randomURL FROM weblinktable WHERE id=1 ");

		while($rows = mysql_fetch_array($getURLresult))
		{
				//echo $rows['randomURL'];
			$theFileToken = $rows['randomURL'];
			
		}

	
echo '$theFileToken: ' . $theFileToken;
echo '$incomingSecretPost: ' . $incomingSecretPost;

    
	
	mysql_close($con);

?>

	<form id="myForm" action="BalloonPop/index.php" method="post">
<?php
    foreach ($_POST as $a => $b) {
        echo '<input type="hidden" name="'.htmlentities($a).'" value="'.htmlentities($b).'">';
    }
		 echo '<input type="hidden" name="token" value="'.$random_token .'">';
		
?>
</form>
	
<script type="text/javascript">
	<?php
	
	 if($theFileToken == $incomingSecretPost){
	   echo 'document.getElementById("myForm").submit();';
	 }else{
		echo 'The access is not authorized.';
	 }
       //document.getElementById('myForm').submit();
	?>
</script>

</body>

</html>