Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="pl">
- <head>
- <meta charset="UTF-8">
- <title>Document</title>
- </head>
- <body>
- <?php
- session_start();
- if(!isset($_SESSION['liczba']) || empty($_SESSION['liczba']))
- {
- $_SESSION['liczba'] = rand(1,5);
- $_SESSION['ile'] = 1;
- }
- ?>
- <form action="" method="post">
- Podaj liczbe o której myśle (od 1 do 5): <input type="number" name="liczba" min=1 max=5 > <br>
- <input type="submit" name="subbutton" value="Wyślij">
- </form>
- <?php
- if(!empty($_POST['subbutton']))
- {
- if($_POST['liczba']>$_SESSION['liczba'])
- {
- echo "Za dużo! Spróbuj jeszcze raz! <br> Strona odświeży się za 3 sekundy...";
- $_SESSION['ile']++;
- header("Refresh: 3");
- exit();
- }
- else if ($_POST['liczba']<$_SESSION['liczba'])
- {
- echo "Za mało! Spróbuj jeszcze raz! <br> Strona odświeży się za 3 sekundy...";
- $_SESSION['ile']++;
- header("Refresh: 3");
- exit();
- }
- else
- {
- echo "Udało Ci się za ".$_SESSION['ile']." razem! Gratulacje!<br> Strona odświeży się za 3 sekundy...";
- session_destroy();
- header("Refresh: 3");
- exit();
- }
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement