This repository has been archived by the owner on May 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
handle_reg6.php
68 lines (62 loc) · 1.7 KB
/
handle_reg6.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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Registration</title>
<style type="text/css" media="screen">
.error { color:red; }
</style>
</head>
<body>
<h1>Registration Results</h1>
<?php
$okay = true;
//empty() checks for an empty variable
//isset() check if a variable has a value
//is_numeric() checks if a variable is a number
if (empty($_POST['email'])) {
print '<p class="error"> Please enter your email.</p>';
$okay=false;
}
if (empty($_POST['password'])) {
print '<p class="error"> Please enter a password</p>';
$okay=false;
}
if (is_numeric($_POST['year'])){
$age = 2016 - $_POST['year'];
}
else {
print '<p class="error"> Please enter birth year as 4 digits!</p>';
}
if ($_POST['password'] != $_POST['confirm']) {
print '<p class="error"> Passwords don\'t match!</p>';
$okay=false;
}
if ($_POST['year']>=2016) {
print '<p class="error"> Are you from the future or is your birth year wrong?</p>';
$okay = false;
}
switch ($_POST['color1']){
case 'red':
$color_type='primary';
break;
case 'yellow':
$color_type='primary';
break;
case 'blue'):
$color_type='primary';
break;
case 'green':
$color_type='secondary';
break;
default:
print '<p class="error"> Please pick a color!</p>';
$okay=false;
}
if ($okay) {
print '<p>You have been successfully registered /s.</p>';
print '<p>You will be $age years this year</p>';
}
?>
</body>
</html>