This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
83 lines (83 loc) · 2.21 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
<!DOCTYPE html>
<html lang="en">
<head>
<style>
* {
margin: 0;
padding: 0;
font-size: 17px;
}
body {
background-color: dimgray;
}
#container {
text-align: center;
margin-top: 30vh;
display: flex;
flex-direction: column;
}
form {
background-color: darkgray;
display: flex;
flex-direction: column;
}
form > * {
margin: 5px auto;
}
#submit {
border-style: none;
width: 50px;
background: inherit;
}
#subimg {
height: 50px;
border-radius: 6px;
transition: ease-in-out .15s;
}
#subimg:hover {
filter: invert();
}
#result {
width: 50vw;
margin: 20px auto;
background-color: black;
padding: 20px;
}
#dice {
}
</style>
</head>
<body>
<div id="container">
<form action="" autocomplete="off" method="get">
<input type="number" name="amount" placeholder="How many dice to roll?" required>
<button id="submit" type="submit"><img id="subimg" src="dice/dice-target.svg"></button>
</form>
<hr>
<div id="result">
<div id="dice">
<?php
if (isset($_GET['amount'])) {
$amount = intval($_GET['amount']);
$total = 0;
if ($amount == True) {
for ($i = 0;$i < $amount;$i++) {
$value = rand(1,6);
$total += $value;
echo('
<img width="50px;" loading="lazy" src="dice/'.$value.'.svg">
');
}
echo('</div><span style="color: white;">Rolled '.$amount.' dice worth '.$total.'</span>');
} else {
echo('Value must be an integer');
}
} else {
echo('ELSE');
}
?>
</div>
</div>
</div>
</body>
</html>