瀏覽代碼

add sub to session

reset game link
SESSION
Ruben De Baets 2 年之前
父節點
當前提交
b16b9be4e0
共有 1 個文件被更改,包括 18 次插入8 次删除
  1. 18
    8
      index.php

+ 18
- 8
index.php 查看文件

@@ -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…
取消
儲存