Location: PHPKode > projects > Crown of Evanion > final/random.php
<?php
/*
*   This file is part of 'Crown of Evanion'.
*
*    'Crown of Evanion' is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    'Crown of Evanion' is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License
*    along with 'Crown of Evanion'; if not, write to the Free Software
*    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/
$title = "Random Money";
include("include.php");

if(!$Username) {
	header("Location: login.php");
}
$errors = array(
'1' => "<h5>You can't play this game again so soon!</h5>",
);

if(!$page) {
	echo "<div align=\"center\">
	$errors[$error]
	<p>Welcome to your standard random money game. You can play this every 15 minutes or so. 
	Who knows, you might even find some sort of rare item.</p>
	<form action=\"$PHP_SELF\" method=\"GET\">
	<input type=\"hidden\" name=\"page\" value=\"play\">
	<input type=\"submit\" value=\"Play!\">
	</form>
	</div>";
}

if($page == "play") {
	if($user_data[random] > $timeofu) {
		header("location: $PHP_SELF?error=1");
		die;
	}
	
	$win = rand(1,40);
	
	$time = $timeofu+900;
	
	mysql_query("UPDATE users SET random = '$time' WHERE id = '$UserID'");
	mysql_query("UPDATE users SET money = money+$win WHERE id = '$UserID'");
	echo "<div align=\"center\">
	<h3>Congratulations!</h3>
	<p>You have won $win moneys!</p>";
}	
include("footer.php");
?>
Return current item: Crown of Evanion