i have made a slot machine, simple really just some random numbers stored as variables with a mysql backend to keep track of points. i decided to set it up so if a guest comes to use the slots each person gets their own temp account based on their IP and a universal password “guest”.
the same data base holds the temp accounts and members for convenience. now the “members” all show up perfectly. the pot amount, how many points they have etc. the problem is the temps do not.
you can view the slot machine &temp account here: http://sirussofts.net84.net/slots/sql_connect.php
you can view the slot machine &member account here: http://sirussofts.net84.net/slots/sql_connect.php?user=test&password=test
and you can view the database here :http://sirussofts.net84.net/slots/admin.php
[php]
$IP = $_SERVER[‘REMOTE_ADDR’];
mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error());
mysql_select_db($mysql_database) or die(mysql_error());
$data = mysql_query(“SELECT * FROM Slots WHERE user=’$user’”) or die(mysql_error());
$user = $_REQUEST[‘user’];
$password = $_REQUEST[‘password’];
function popup($s){
echo “”;
}
if(!isset($user) && !isset($password)){
$user = md5($IP);
$password = “guest”;
if($user !== $data[‘user’]){
@mysql_query(“INSERT INTO Slots VALUES(’$user’,’$password’,‘guest’,‘0’,’$IP’,‘50’,‘100’,‘0’,‘0’)”);
@mysql_query(“INSERT INTO twisted titanium
VALUES(‘0’, ‘$user’, ‘1’, ‘1’, ‘100’, ‘100’, ‘100’, ‘100’)”);
$url = $_SERVER[‘REQUEST_URI’] . ‘?user=’.$user.’&password=’.$password;
header(“location:$url”);
}
if($user == $data[‘user’]){
$url = $_SERVER[‘REQUEST_URI’] . ‘?user=’.$user.’&password=’.$password;
popup(“welcome back Guest”);
}
}
if (isset($_REQUEST[’_SESSION’])) die(“Get lost Muppet!”);
$cashamt = mysql_query(“SELECT cashamt FROM Slots WHERE user=’$user’”) or die(mysql_error());
$pot_amount = mysql_query(“SELECT potamt FROM Slots WHERE user=’$user’”) or die(mysql_error());
mysql_query(“UPDATE Slots SET IP=’$IP’ where user=’$user’”)or die(mysql_error());
$paid="";
$win = false;
$slot_space1 = rand(0,9);
$slot_space2 = rand(0,9);
$slot_spot1 = rand($slot_space1,$slot_space2);
$slot_spot2 = rand($slot_space1,$slot_space2);
$slot_spot3 = rand($slot_space1,$slot_space2);
if($slot_spot1<8){
$slot_spot1 = $slot_spot1+1;
}
if($slot_spot2>2){
$slot_spot2 = $slot_spot2-1;
}
if($slot_spot3>3){
$slot_spot3 = $slot_spot3-2;
}
$wins = array(2,4,6);
$sel_num = array($slot_spot1,$slot_spot2,$slot_spot3);
$win_multiplier = rand(0,3);
echo "user: $user ";
echo "password: $password ";
if($sel_num[0] == 2 && $sel_num[1] == 2 && $sel_num[2] == 2){
popup(“YOU HAVE WON Fifteen points WITH $wins[0]”);
mysql_query(“UPDATE Slots SET cashamt=cashamt+17 where user=’$user’”) or die(mysql_error());
$win = true;
}else{}
if($sel_num[0] == 4 && $sel_num[1] == 4&& $sel_num[2] == 4){
popup(“YOU HAVE WON 1 point WITH $wins[1]”);
mysql_query(“UPDATE Slots SET cashamt=cashamt+4 where user=’$user’”) or die(mysql_error());
$win = true;
}else{}
if($sel_num[0] == 6 && $sel_num[1] == 6 && $sel_num[2] == 6){
popup(“YOU HAVE WON 3 points WITH $wins[2]”);
mysql_query(“UPDATE Slots SET cashamt=cashamt+6 where user=’$user’”) or die(mysql_error());
$win = true;
}else{}
if($sel_num[0] == 8 && $sel_num[1] == 8 && $sel_num[2] == 8){
popup(“you have Triple 8’s on the board”);
mysql_query(“UPDATE Slots SET cashamt=cashamt+’$pot_amount’ where user=’$user’”) or die(mysql_error());
$win = true;
}
$result = mysql_query(“SELECT cashamt, potamt FROM Slots
WHERE user=’$user’”);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
$pot_amount = $row[‘potamt’];
$cashamt = $row[‘cashamt’];
echo <<<EOF
background-position: top center;
background-repeat: no-repeat;
background-attachment: fixed;
}
#wrapper, #container {
height: 500px;
width: 600px;
}
#wrapper {
position: absolute;
bottom: 50%;
right: 50%;
height: 500px;
width: 600px;
}
#container {
position: relative;
left: 50%;
top: 50%;
}
.style2 {color: #FFFFFF}
.style4 {
font-size: 16px;
font-weight: bold;
}
.style5 {color: #00FF00}
.style8 {font-size: 18px}
.style9 {color: #808080}
p, h1, form, button{border:0; margin:0; padding:0;}
input.black {
background-color:#000000;
border: 1px solid #ffffff;
}
.black {
color:ffffff;
}
.greengui2 {
font-weight: bold; font-family:“Courier New”, Courier, monospace; color:#0f6; font-size:12px;
}
.greengui {
font-weight: bold; font-family:“ourier New”, Courier, monospace; color:#0cf; font-size:12px;
}
.orangegui {
font-weight: bold; font-family:“Courier New”, Courier, monospace; color:#F90; font-size:12px;
}
–>