hlgame.php
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
session_start();
$nummer1 = (isset($_SESSION['nummer1'])) ? $_SESSION['nummer1'] : rand(0, 100);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$nummer2 = rand(0, 100);
if (isset($_POST['hoger'])) {
if ($nummer1 > $nummer2) {
echo '<center>Het getal was <b>'.$nummer1.'</b>, het nieuwe getal was <b>'.$nummer2.'</b>.<br>Het nieuwe getal was lager, dus <b><p style="color: red">je verliest!</p></b></center>';
} else {
echo '<center>Het getal was <b>'.$nummer1.'</b>, het nieuwe getal was <b>'.$nummer2.'</b>.<br>Het nieuwe getal was hoger, dus <b><p style="color: green">je wint!</p></b></center>';
}
} else {
if ($nummer1 < $nummer2) {
echo '<center>Het getal was <b>'.$nummer1.'</b>, het nieuwe getal was <b>'.$nummer2.'</b>.<br>Het nieuwe getal was hoger, dus <b><p style="color: red">je verliest!</p></b></center>';
} else {
echo '<center>Het getal was <b>'.$nummer1.'</b>, het nieuwe getal was <b>'.$nummer2.'</b>.<br>Het nieuwe getal was lager, dus <b><p style="color: green">je wint!</p></b></center>';
}
}
}
?>
<center>
Het getal is <b>
<?php
$nummer1 = rand(0, 100);
echo $nummer1;
$_SESSION['nummer1'] = $nummer1;
?>
</b><br>Is het volgende getal...<br><br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="hoger" value="Hoger"> of <input type="submit" name="lager" value="Lager">?
</form>
<style>
html, body {
margin: 0;
padding: 0;
background-color: #f2f2f2;
height: 100%;
line-height: 1.4em;
}
html, body, th, td, input, textarea, select {
font: 11px Verdana, Arial, Helvetica, sans-serif;
color: #000;
}
a, a:link, a:visited, a:active {
color: #17407e;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
input, textarea {
background: #fff;
border: 1px #ddd solid;
border-bottom: 2px #ddd solid;
padding: 1px;
}
button {
font: 700 11px Verdana, Arial, Helvetica, sans-serif;
}
img {
border: 0;
}
table {
width: 100%;
}
th {
font-weight: 700;
}
h1 {
font: 700 16px Verdana, Arial, Helvetica, sans-serif;
}
h2 {
font: 700 15px Verdana, Arial, Helvetica, sans-serif;
}
h3 {
font: 700 14px Verdana, Arial, Helvetica, sans-serif;
}
</style></center>
ini_set('display_errors', 1); // 0 = uit, 1 = aan
error_reporting(E_ALL);
session_start();
$nummer1 = (isset($_SESSION['nummer1'])) ? $_SESSION['nummer1'] : rand(0, 100);
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$nummer2 = rand(0, 100);
if (isset($_POST['hoger'])) {
if ($nummer1 > $nummer2) {
echo '<center>Het getal was <b>'.$nummer1.'</b>, het nieuwe getal was <b>'.$nummer2.'</b>.<br>Het nieuwe getal was lager, dus <b><p style="color: red">je verliest!</p></b></center>';
} else {
echo '<center>Het getal was <b>'.$nummer1.'</b>, het nieuwe getal was <b>'.$nummer2.'</b>.<br>Het nieuwe getal was hoger, dus <b><p style="color: green">je wint!</p></b></center>';
}
} else {
if ($nummer1 < $nummer2) {
echo '<center>Het getal was <b>'.$nummer1.'</b>, het nieuwe getal was <b>'.$nummer2.'</b>.<br>Het nieuwe getal was hoger, dus <b><p style="color: red">je verliest!</p></b></center>';
} else {
echo '<center>Het getal was <b>'.$nummer1.'</b>, het nieuwe getal was <b>'.$nummer2.'</b>.<br>Het nieuwe getal was lager, dus <b><p style="color: green">je wint!</p></b></center>';
}
}
}
?>
<center>
Het getal is <b>
<?php
$nummer1 = rand(0, 100);
echo $nummer1;
$_SESSION['nummer1'] = $nummer1;
?>
</b><br>Is het volgende getal...<br><br>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" name="hoger" value="Hoger"> of <input type="submit" name="lager" value="Lager">?
</form>
<style>
html, body {
margin: 0;
padding: 0;
background-color: #f2f2f2;
height: 100%;
line-height: 1.4em;
}
html, body, th, td, input, textarea, select {
font: 11px Verdana, Arial, Helvetica, sans-serif;
color: #000;
}
a, a:link, a:visited, a:active {
color: #17407e;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
input, textarea {
background: #fff;
border: 1px #ddd solid;
border-bottom: 2px #ddd solid;
padding: 1px;
}
button {
font: 700 11px Verdana, Arial, Helvetica, sans-serif;
}
img {
border: 0;
}
table {
width: 100%;
}
th {
font-weight: 700;
}
h1 {
font: 700 16px Verdana, Arial, Helvetica, sans-serif;
}
h2 {
font: 700 15px Verdana, Arial, Helvetica, sans-serif;
}
h3 {
font: 700 14px Verdana, Arial, Helvetica, sans-serif;
}
</style></center>