Jump to content
MakeWebGames

Roulette [Simple] [FREE!]


Kakashi

Recommended Posts

Simple roulette, simply if you can guess a number between 1 - 18, you win! Prices and stuff are very easy to edit.

 

<?

include 'header.php';

$guess = abs((int) $_POST['guess']);

if($guess < 0 or $guess > 18){

echo Message("<center>Error. You must enter a number between 0 and 18. [Go Back]");

include "footer.php";

die();

}

if (isset($_POST['predict'])) {

if ($user_class->money < 300){

echo Message("<center>You don't have enough money to spin.</center>");

} else {

$newmoney = $user_class->money - 300;

$result = mysql_query("UPDATE `grpgusers` SET `money` = '".$newmoney."' WHERE `id`='".$user_class->id."'");

$user_class = new User($_SESSION['id']);

 

$roulette = rand(0,18);

echo '<tr><td class="contenthead">Spin Results</td></tr><tr><td class="contentcontent" align="center">';

echo "The result of the roulette was $roulette and you predicted it was $guess.";

echo "</td></tr>";

if($roulette == $_POST['guess']){

$newmoney = $user_class->money + 2600;

$result = mysql_query("UPDATE `grpgusers` SET `money` = '".$newmoney."' WHERE `id`='".$user_class->id."'");

$user_class = new User($_SESSION['id']);

echo Message("<center>Congratulations, you have won $2500!</center>");

} else {

echo Message("<center>Sorry. You didn't win anything.</center>");

}

}

}

?>

<tr><td class="contenthead">Roulette (Cash)</td></tr>

<tr><td class="contentcontent">

<center>

roulette.jpg

</center>

</td></tr>

<tr><td class="contentcontent">

<center>

So, you fancy a spin at the roulette? Well, it just $300 a go, so have at it.

 

<form method='post'>

<table align="center">

<tr>

<td>Predicted Number (0 - 18):</td><td><input type='text' name='guess' value='<?php echo("$guess"); ?>' size='10' maxlength='20'></td>

</tr>

<td colspan="2"><input type='submit' name='predict' value='Predict'>

</form>

</center>

</td></tr>

<?

include 'footer.php';

?>

Call this roulette.php

And thats all, no other files required.

Thanks, feedback is GREATLY appreciated.

Kakashi :P

Link to comment
Share on other sites

.
Pointless post?

Anyway, you are using short tags EG:They wont be used in php 6?

Oh sorry, I was using PHP 5, in cPanel, you can use the long tags on PHP6, yes.

 

.
Pointless post?

Anyway, you are using short tags EG:They wont be used in php 6?

.
Pointless post?

Anyway, you are using short tags EG:They wont be used in php 6?

Oh sorry, I was using PHP 5, in cPanel, you can use the long tags on PHP6, yes.

And it is already secured enough. Unless you are using a badly shared server which can be vunerable.

Link to comment
Share on other sites

Use full PHP tags (which are recommended).

Two reasons:

(1). Not all hosting providers have or allow short style PHP tags enabled.

(2). To make sure your code will always work as full PHP tags will continue to work within future versions of PHP as the other alternatives may not.

Link to comment
Share on other sites

Use full PHP tags (which are recommended).

Two reasons:

(1). Not all hosting providers have or allow short style PHP tags enabled.

(2). To make sure your code will always work as full PHP tags will continue to work within future versions of PHP as the other alternatives may not.

Good point. I'll code the rest of my codes with the longer versions from now on. :thumbsup:
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...