Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. <?php
  2. echo "<html><head><title>Calculator Game From 1998</title></head><body>";
  3. echo "<h1>Please Guess The Answer</h1>";
  4. echo "<form name = "myfirstform" action = "formprocess.php" method = "POST">";
  5. echo "Enter Integer Between 1-5<br>";
  6. echo "<input type = "text" name = "firstdata">";
  7. echo "<br> <input type= "submit" value = "submit">";
  8. echo "</form>";
  9. echo "</body></html>";
  10. ?>
  11.  
  12. <?php
  13. $random = rand(1, 5);
  14. echo "<html><head><title>Answer</title></head><body>";
  15. if ($_POST["firstdata"] == $random) {
  16. echo "<h1><font color="green">Congrulations!</h1></font><br>";
  17. echo "<h2>Answer was: </h2>";
  18. echo $random;
  19. echo "<br>";
  20. echo "<a href="try.php">new game</a>";
  21. }
  22. else {
  23. echo "<h1><font color="red">Nope wrong answer</h1></font><br>";
  24. echo "<h2>Answer was: </h2>";
  25. echo $random;
  26. echo "<br>";
  27. echo "<a href="try.php">new game</a>";
  28. }
  29. echo "</body></html>";
  30. ?>
  31.  
  32. $win = 0;
  33. $lost = 0;
  34.  
  35. <?php
  36. session_start();
  37. if (!isset($_SESSION['wins']) || !isset($_SESSION['losses'])) {
  38. $_SESSION['wins'] = 0;
  39. $_SESSION['losses'] = 0;
  40. }
  41.  
  42. if ($_POST["firstdata"] == $random) {
  43. $_SESSION['wins']++;
  44. // other stuff...
  45. } else {
  46. $_SESSION['losses']++;
  47. // other stuff
  48. }
  49.  
  50. echo "<p>You've won {$_SESSION['wins']} games and lost {$_SESSION['losses']}.</p>";
  51.  
  52. <?php
  53. session_start();
  54. if (!isset($_SESSION['win'])) {
  55. $_SESSION['win'] = 0;
  56. }
  57.  
  58. // ...
  59.  
  60. if ($_POST["firstdata"] == $random) {
  61. $_SESSION['win'] += 1;
  62.  
  63. // ...
  64.  
  65. $_SESSION['win'] = $win;
  66.  
  67. $_SESSION['win'] = ($_SESSION['win'] + $win);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement