Kakashi Posted May 15, 2010 Posted May 15, 2010 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> </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 Quote
SlanderDesign Posted May 17, 2010 Posted May 17, 2010 Well sorted some minor issues. You're unable to view this code. Viewing code within this forum requires registration, you can register here for free. In some of the queries it uses '".$val."' This causes little exploits on some pages "attack.php" Remove all ' in the queries you don't need them! Quote
SlanderDesign Posted May 18, 2010 Posted May 18, 2010 If it's stored as a number don't use strings. I did mean to put that but couldn't remember ;P thanks DJK Quote
SlanderDesign Posted May 19, 2010 Posted May 19, 2010 .Pointless post? Anyway, you are using short tags EG:<? instead of normal tags <?php... They wont be used in php 6? Quote
Kakashi Posted May 19, 2010 Author Posted May 19, 2010 .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. Quote
Djkanna Posted May 19, 2010 Posted May 19, 2010 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. Quote
Kakashi Posted May 19, 2010 Author Posted May 19, 2010 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: Quote
Kakashi Posted May 27, 2010 Author Posted May 27, 2010 nice work seems to work flawlesslyThank your feedback, means a lot! :) :thumbsup: Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.