Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Document</title>
- </head>
- <body>
- <?php
- session_start();
- if (!isset($_SESSION['number']) || (isset($_GET['number']) && $_GET['number'] == 'new')) {
- $_SESSION['number'] = rand(0, 100);
- $_SESSION['try'] = 0;
- $_SESSION['tries'] = array();
- $_SESSION['done'] = false;
- }
- echo 'a keresendő érték:' . $_SESSION['number'] . '<BR>';
- if (isset($_POST['submit'])) {
- $probak = $_SESSION['tries'];
- $probak[] = $_POST['number'];
- $_SESSION['tries'] = $probak;
- $_SESSION['try']++;
- if ($_POST['number'] < $_SESSION['number']) {
- echo 'a keresett szám nagyobb, mint ' . $_POST['number'] . '<BR>';
- } else
- if ($_POST['number'] > $_SESSION['number']) {
- echo 'a keresett szám kisebb, mint ' . $_POST['number'] . '<BR>';
- } else {
- echo 'megtaláltad a keresett számot!' . $_SESSION['number'] . '<BR>';
- $_SESSION['done'] = true;
- }
- echo 'A próbálkozások száma:' . $_SESSION['try'] . '<BR>';
- }
- foreach ($_SESSION['tries'] as $k => $v) {
- echo ($k + 1) . ' --> ' . $v . '<BR>';
- }
- echo '<BR><a href="games2.php?number=new">Új szám generálása</a>';
- if (!$_SESSION['done']) {
- echo '
- <FORM NAME="form1" method="POST" action="games2.php">
- <INPUT type="text" name="number">
- <INPUT type="submit" name="submit" value="Probal">
- </FORM>
- ';
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement