Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- echo "<html><head><title>Calculator Game From 1998</title></head><body>";
- echo "<h1>Please Guess The Answer</h1>";
- echo "<form name = "myfirstform" action = "formprocess.php" method = "POST">";
- echo "Enter Integer Between 1-5<br>";
- echo "<input type = "text" name = "firstdata">";
- echo "<br> <input type= "submit" value = "submit">";
- echo "</form>";
- echo "</body></html>";
- ?>
- <?php
- $random = rand(1, 5);
- echo "<html><head><title>Answer</title></head><body>";
- if ($_POST["firstdata"] == $random) {
- echo "<h1><font color="green">Congrulations!</h1></font><br>";
- echo "<h2>Answer was: </h2>";
- echo $random;
- echo "<br>";
- echo "<a href="try.php">new game</a>";
- }
- else {
- echo "<h1><font color="red">Nope wrong answer</h1></font><br>";
- echo "<h2>Answer was: </h2>";
- echo $random;
- echo "<br>";
- echo "<a href="try.php">new game</a>";
- }
- echo "</body></html>";
- ?>
- $win = 0;
- $lost = 0;
- <?php
- session_start();
- if (!isset($_SESSION['wins']) || !isset($_SESSION['losses'])) {
- $_SESSION['wins'] = 0;
- $_SESSION['losses'] = 0;
- }
- if ($_POST["firstdata"] == $random) {
- $_SESSION['wins']++;
- // other stuff...
- } else {
- $_SESSION['losses']++;
- // other stuff
- }
- echo "<p>You've won {$_SESSION['wins']} games and lost {$_SESSION['losses']}.</p>";
- <?php
- session_start();
- if (!isset($_SESSION['win'])) {
- $_SESSION['win'] = 0;
- }
- // ...
- if ($_POST["firstdata"] == $random) {
- $_SESSION['win'] += 1;
- // ...
- $_SESSION['win'] = $win;
- $_SESSION['win'] = ($_SESSION['win'] + $win);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement