Browse Source

add sub to session

reset game link
SESSION
Ruben De Baets 2 years ago
parent
commit
b16b9be4e0
1 changed files with 18 additions and 8 deletions
  1. 18
    8
      index.php

+ 18
- 8
index.php View File

@@ -1,5 +1,9 @@
<html>
<?php
session_start();
var_dump($_SESSION);

?>

<head>

@@ -9,9 +13,14 @@
<h1 id="shot">Zeeslag</h1>
<?php

$canal = 5;
$sub = rand(0, $canal - 1);
$ammo = $canal / 5;
if ($_SESSION['sub']) {
$sub = $_SESSION['sub'];
} else {
$canal = 5;
$sub = rand(0, $canal - 1);
$_SESSION['sub'] = $sub;
$ammo = $canal / 5;
}
echo "Sub position: " . $sub;
?>
<h2 id="shot">Invoer</h2>
@@ -28,12 +37,13 @@
$shot = $_POST['shot'];
if ($shot == $sub) {
echo 'Gewonnen';
} else {
echo "Gemist";
}
}
?> <br /><a href="/">Reset Game</a><?php
} else {
echo "Gemist";
}
}

?>
?>
</body>

</html>

Loading…
Cancel
Save