-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhomework10.php
74 lines (55 loc) · 1.19 KB
/
homework10.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
<?php
include_once 'functions.php';
session_start();
$word = ['j','o','r','o'];
$char = getValue($_POST, "char");
if (!isset($_SESSION['count'])) {
$_SESSION['count'] = 0;
$_SESSION['id0'] = '_';
$_SESSION['id1'] = '_';
$_SESSION['id2'] = '_';
$_SESSION['id3'] = '_';
$_SESSION['counts'] = 1;
} else {
$_SESSION['count']++ ;
$_SESSION['counts']++;
}
if($_SESSION['count'] == 4){
unset($_SESSION['count']);
}
$length = count($word);
for($i=0;$i<$length;$i++){
if($word[$i]==$char){
$_SESSION['id'.(string)$i] = $word[$i];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
div >label{
text-align:left;
display:block;
}
</style>
</head>
<body>
<div>
<form action="" method="post">
<div>
<label for="char">Input char</label>
<input type="text" id="char" name="char" />
</div>
<div>
<input type="submit" value="Gues"/>
</div>
</form>
<div><?= $_SESSION['id0']." ".$_SESSION['id1']." ".$_SESSION['id2']." ".$_SESSION['id3']; ?></div>
<div>TRY number:<?php echo $_SESSION['counts'];?></div>
<div>You can try only 5 times !!! </div>
</div>
</body>
</html>