Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. <?php
  2. if (isset($_POST['toss'])) {
  3. $servername = "localhost";
  4. $username = "rbxarena_user";
  5. $password = "u.M0xNUhK6#w";
  6. $dbname = "rbxarena_data";
  7. $conn = new mysqli($servername, $username, $password, $dbname);
  8.  
  9. if ($conn->connect_error) {
  10. die("Connection failed: " . $conn->connect_error);
  11. }
  12.  
  13. $user = $_SESSION['username'];
  14. $bet = $_POST['bet'];
  15. $option = $_POST['selector1'];
  16. $query = "SELECT * FROM users WHERE username='$user'";
  17. $result = mysqli_query($conn, $query);
  18. $row = mysqli_fetch_assoc($result);
  19. $credits = $row['coins'];
  20. $win = ($bet * 2);
  21.  
  22. if ($bet >= 10) {
  23. if ($credits >= 10) {
  24. $game = rand(1,2);
  25. if ($game == 1){
  26. echo '<img style="background: no-repeat;" src="https://vgy.me/MGUtH4.png" alt="Heads" height="150" width="150">';
  27. if ($option == "Heads") {
  28. echo "&nbsp&nbspYou have won";
  29. $query = "UPDATE users SET coins = coins+".$win." WHERE username = '$user'";
  30. $query2 = "UPDATE users SET wins = wins+1 WHERE username = '$user'";
  31. mysqli_query($conn,$query) or die(mysqli_error());
  32. mysqli_query($conn,$query2) or die(mysqli_error());
  33. mysqli_close($conn);
  34. }
  35. else {
  36. echo "&nbsp&nbspSorry you lose :(";
  37. $query = "UPDATE users SET coins = coins-".$bet." WHERE username = '$user'";
  38. mysqli_query($conn,$query) or die(mysqli_error());
  39. mysqli_close($conn);
  40. }
  41. }
  42. else {
  43. echo '<img style="background: no-repeat;" src="https://vgy.me/IW6uzq.png" alt="Tails" height="150" width="150">';
  44. if ($option == "Tails") {
  45. echo "&nbsp&nbspYou have won";
  46. $query = "UPDATE users SET coins = coins+".$win." WHERE username = '$user'";
  47. $query2 = "UPDATE users SET wins = wins+1 WHERE username = '$user'";
  48. mysqli_query($conn,$query) or die(mysqli_error());
  49. mysqli_query($conn,$query2) or die(mysqli_error());
  50. mysqli_close($conn);
  51. }
  52. else {
  53. echo "&nbsp&nbspSorry you lose :(";
  54. $query = "UPDATE users SET coins = coins-".$bet." WHERE username = '$user'";
  55. mysqli_query($conn,$query) or die(mysqli_error());
  56. mysqli_close($conn);
  57. }
  58. }
  59. }
  60. else {
  61. echo "&nbsp&nbspYou dont have enough credits";
  62. }
  63. }
  64.  
  65. else {
  66. echo "Your bet is lower than the minimum.";
  67. }
  68. }
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement