-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
85 lines (84 loc) · 1.56 KB
/
index.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
<table border="2">
<tr>
<td>
<form method="post" action="index.php">
<input type="hidden" name="restart" value="5" />
<input type="submit" value="restart" />
</form>
</td>
<td>
<form method="post" action="index.php">
<input type="hidden" name="gora" value="1" />
<input type="submit" value="gora" />
</form>
</td>
<td></td>
</tr>
<tr>
<td>
<form method="post" action="index.php">
<input type="hidden" name="lewo" value="2" />
<input type="submit" value="lewo" />
</form>
</td>
<td></td>
<td>
<form method="post" action="index.php">
<input type="hidden" name="prawo" value="3" />
<input type="submit" value="prawo" />
</form>
</td>
</tr>
<tr>
<td></td>
<td>
<form method="post" action="index.php">
<input type="hidden" name="dol" value="4" />
<input type="submit" value="dol" />
</form>
</td>
<td></td>
</tr>
</table>
<br />
<?php
session_start();
$posy = 5;
$posx = 5;
if (isset($_POST['restart']))
{
$_SESSION['posx'] = 5;
$_SESSION['posy'] = 5;
$posx = $_SESSION['posx'];
$posy = $_SESSION['posy'];
}
elseif (isset($_POST['gora']))
{
$posy = $_SESSION['posy'] + 1;
$_SESSION['posy'] = $posy;
}
elseif (isset($_POST['lewo']))
{
$posx = $_SESSION['posx'] - 1;
$_SESSION['posx'] = $posx;
}
elseif (isset($_POST['prawo']))
{
$posx = $_SESSION['posx'] + 1;
$_SESSION['posx'] = $posx;
}
elseif (isset($_POST['dol']))
{
$posy = $_SESSION['posy'] - 1;
$_SESSION['posy'] = $posy;
}
$posy = $_SESSION['posy'];
$posx = $_SESSION['posx'];
?>
</ br>Twoja pozycja na mapie(x, y) to :
</ br>
<?php
echo $posx;
echo ', ';
echo $posy;
?>