-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathif.php
executable file
·59 lines (52 loc) · 1.6 KB
/
if.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<fieldset>
<legend>can you drink yet?</legend>
<form action="if.php" method="post">
<label for="">what is your age?:</label><br>
<input type="number" name="age"><br>
<input type="submit" value="submit"><br>
</form>
</fieldset>
<!-- <fieldset>
<legend>are you an adult?</legend>
<form action="if.php" method="post">
<label for="">are you an adult?</label><br>
<select name="select" id="">
<option value="1">yes</option>
<option value="0">no</option>
</select>
<input type="submit" value="submit"><br>
</form>
</fieldset> -->
</body>
</html>
<?php
//if statement = if some condition is true, do something
// if some condition is false, don't do it
$age = $_POST["age"];
if ($age >= 60) {
echo "your older than the spirits you sip! yes you can drink!!!";
} elseif ($age < 0) {
echo "that wasn't a valid age";
} elseif ($age == 0) {
echo "you were just born!";
} elseif ($age >= 21) {
echo "you can drink alcohol";
} else {
$years_until_21 = 21 - $age;
echo "you cannot drink for {$years_until_21} more years.";
}
// $adult = $_POST["select"];
// if($adult) {
// echo 'you are an adult';
// } else {
// echo 'you are not an adult';
// }
?>