Free high low casino game.. Enjoy..
v1
Create highlow.php with:
<?php
/*-----------------------------------------------------
-- High Low (Free Source)
-- Copyright held 2007-2008 Isomerizer.com
-- highlow.php
-----------------------------------------------------*/
session_start();
require "global_func.php";
if($_SESSION['loggedin']==0) { header("Location: login.php");exit; }
$userid=$_SESSION['userid'];
require "header.php";
$h = new headers;
$h->startheaders();
include "mysql.php";
global $c;
$is=mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us ON u.userid=us.userid WHERE u.userid=$userid",$c) or die(mysql_error());
$ir=mysql_fetch_array($is);
check_level();
$fm=money_formatter($ir['money']);
$cm=money_formatter($ir['crystals'],'');
$lv=date('F j, Y, g:i a',$ir['laston']);
$h->userdata($ir,$lv,$fm,$cm);
$h->menuarea();
switch($_GET['action'])
{
default: highlow_index(); break;
case 'bet': bet(); break;
case 'bet2': bet2(); break;
}
if ($_GET['action']!="bet" || $_GET['action']!="bet2") { echo 'What are you doing?
[url="highlow.php"]Back[/url]'; $h->endpage(); exit; }
function highlow_index()
{
global $ir,$c,$userid,$h;
if ($_SESSION['card']!=0 || $_SESSION['bet']!=0)
{
$recent=$_SESSION['bet'];
echo 'You are already in a game of high low.
';
$h->endpage();
exit;
}
$max=$ir['level']*5;
echo 'High LowWelcome to the casino game of High Low, There are 10 cards, 1 to 10.
You must pick either lower or higher to win.
[b]State your wager: [i](Your max bet is $'.$max.')[/i][/b]
Bet: $
The maximum bet is your current level x $5.';
$h->endpage();
exit;
}
function bet()
{
global $ir,$c,$userid,$h;
if ($ir['money']<$_POST['amount'])
{
echo 'Error - You dont have that much money.
[url="highlow.php"]Back[/url]';
$h->endpage();
exit;
}
if ($_POST['amount']<=0)
{
echo 'Error - You cant bet under $1.
[url="highlow.php"]Back[/url]';
$h->endpage();
exit;
}
$max=$ir['level']*5;
if ($_POST['amount']>$max)
{
echo 'Error - Max Bet Exceeded.
[url="highlow.php"]Back[/url]';
$h->endpage();
exit;
}
if ($_SESSION['card']==0)
{
$card=mt_rand(1,10);
$_SESSION['card']=$card;
}
$card=$_SESSION['card'];
$amount=mysql_real_escape_string($_POST['amount']);
$_SESSION['bet']=$amount;
echo 'High LowYou lay $'.$amount.' on the table
The dealer reveals the card '.$card.'.
Will you bet on higher or lower?
Higher
Lower
';
$h->endpage();
exit;
}
function bet2()
{
global $ir,$c,$userid,$h;
$dealercard=$_SESSION['card'];
$yourcard=mt_rand(1,10);
echo 'High LowYou bet '.$_POST['decide'].'
The final result is:
[b]Dealers Card:[/b] '.$dealercard.'
[b]Your Card:[/b] '.$yourcard.'
';
$prize=mysql_real_escape_string($_SESSION['bet']);
$lose=$ir['money']-$prize;
$win=$ir['money']+$prize;
$_SESSION['bet']=0;
$_SESSION['card']=0;
if ($yourcard==$dealercard)
{
echo 'You drew with the dealer!
[url="highlow.php"]Back[/url]';
$h->endpage();
exit;
}
if ($_POST['decide']=="higher" && $yourcard>$dealercard)
{
echo 'Congratulations you won $'.$prize.' !
[url="highlow.php"]Back[/url]';
mysql_query("UPDATE users SET money=$win WHERE userid=$userid", $c);
$h->endpage();
exit;
}
if ($_POST['decide']=="higher" && $yourcard<$dealercard)
{
echo 'Sorry, You lost $'.$prize.' !
[url="highlow.php"]Back[/url]';
mysql_query("UPDATE users SET money=$lose WHERE userid=$userid", $c);
$h->endpage();
exit;
}
if ($_POST['decide']=="lower" && $yourcard<$dealercard)
{
echo 'Congratulations you won $'.$prize.' !
[url="highlow.php"]Back[/url]';
mysql_query("UPDATE users SET money=$win WHERE userid=$userid", $c);
$h->endpage();
exit;
}
if ($_POST['decide']=="lower" && $yourcard>$dealercard)
{
echo 'Sorry, you lost $'.$prize.' !
[url="highlow.php"]Back[/url]';
mysql_query("UPDATE users SET money=$lose WHERE userid=$userid", $c);
$h->endpage();
exit;
}
}
?>
v2
Create highlow.php with:
<?php
/*-----------------------------------------------------
-- High Low (Free Source)
-- Copyright held 2007-2008 Isomerizer.com
-- highlow.php
-----------------------------------------------------*/
require "globals.php";
switch($_GET['action'])
{
default: highlow_index(); break;
case 'bet': bet(); break;
case 'bet2': bet2(); break;
}
if ($_GET['action']!="bet" || $_GET['action']!="bet2") { echo 'What are you doing?
[url="highlow.php"]Back[/url]'; $h->endpage(); exit; }
function highlow_index()
{
global $ir,$c,$userid,$h;
if ($_SESSION['card']!=0 || $_SESSION['bet']!=0)
{
$recent=$_SESSION['bet'];
echo 'You are already in a game of high low.
';
$h->endpage();
exit;
}
$max=$ir['level']*5;
echo 'High LowWelcome to the casino game of High Low, There are 10 cards, 1 to 10.
You must pick either lower or higher to win.
[b]State your wager: [i](Your max bet is $'.$max.')[/i][/b]
Bet: $
The maximum bet is your current level x $5.';
$h->endpage();
exit;
}
function bet()
{
global $ir,$c,$userid,$h;
if ($ir['money']<$_POST['amount'])
{
echo 'Error - You dont have that much money.
[url="highlow.php"]Back[/url]';
$h->endpage();
exit;
}
if ($_POST['amount']<=0)
{
echo 'Error - You cant bet under $1.
[url="highlow.php"]Back[/url]';
$h->endpage();
exit;
}
$max=$ir['level']*5;
if ($_POST['amount']>$max)
{
echo 'Error - Max Bet Exceeded.
[url="highlow.php"]Back[/url]';
$h->endpage();
exit;
}
if ($_SESSION['card']==0)
{
$card=mt_rand(1,10);
$_SESSION['card']=$card;
}
$card=$_SESSION['card'];
$amount=$db->real_escape_string($_POST['amount']);
$_SESSION['bet']=$amount;
echo 'High LowYou lay $'.$amount.' on the table
The dealer reveals the card '.$card.'.
Will you bet on higher or lower?
Higher
Lower
';
$h->endpage();
exit;
}
function bet2()
{
global $ir,$c,$userid,$h;
$dealercard=$_SESSION['card'];
$yourcard=mt_rand(1,10);
echo 'High LowYou bet '.$_POST['decide'].'
The final result is:
[b]Dealers Card:[/b] '.$dealercard.'
[b]Your Card:[/b] '.$yourcard.'
';
$prize=$db->real_escape_string($_SESSION['bet']);
$lose=$ir['money']-$prize;
$win=$ir['money']+$prize;
$_SESSION['bet']=0;
$_SESSION['card']=0;
if ($yourcard==$dealercard)
{
echo 'You drew with the dealer!
[url="highlow.php"]Back[/url]';
$h->endpage();
exit;
}
if ($_POST['decide']=="higher" && $yourcard>$dealercard)
{
echo 'Congratulations you won $'.$prize.' !
[url="highlow.php"]Back[/url]';
$db->query("UPDATE users SET money=$win WHERE userid=$userid", $c);
$h->endpage();
exit;
}
if ($_POST['decide']=="higher" && $yourcard<$dealercard)
{
echo 'Sorry, You lost $'.$prize.' !
[url="highlow.php"]Back[/url]';
$db->query("UPDATE users SET money=$lose WHERE userid=$userid", $c);
$h->endpage();
exit;
}
if ($_POST['decide']=="lower" && $yourcard<$dealercard)
{
echo 'Congratulations you won $'.$prize.' !
[url="highlow.php"]Back[/url]';
$db->query("UPDATE users SET money=$win WHERE userid=$userid", $c);
$h->endpage();
exit;
}
if ($_POST['decide']=="lower" && $yourcard>$dealercard)
{
echo 'Sorry, you lost $'.$prize.' !
[url="highlow.php"]Back[/url]';
$db->query("UPDATE users SET money=$lose WHERE userid=$userid", $c);
$h->endpage();
exit;
}
}
?>
Both Versions
Add to logout.php:
After <?php
ob_start();
&&
Before
session_unset();
session_destroy();
add:
if ($_SESSION['card']!=0 || $_SESSION['bet']!=0)
{
$fee=$_SESSION['bet'];
mysql_query("UPDATE users SET money=money-$fee WHERE userid=$sessid", $c);
$_SESSION['card']=0;
$_SESSION['bet']=0;
}
Thanks, Can be seen fully working @ www.amazon-survival.com