-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
171 lines (155 loc) · 5.7 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
require __DIR__ . "/vendor/autoload.php";
require __DIR__ . "/user.php";
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
* {
margin: 0; padding: 0; box-sizing: border-box;
}
body {
min-height: 100vh;
display: flex; justify-content: center; align-items: center;
background-color: rgb(238, 241, 241);
font-family: Verdana, sans-serif;
font-size: 12px;
}
form {
background-color: #fff;
padding: 20px;
}
form div label, form div input { display: block; }
form div:first-child { display: none; }
form div.visible { display: block; }
form div:first-child p {
padding: 10px;
margin-bottom: 10px;
background-color: #84f495;
color: #222;
}
form div label {
text-transform: uppercase;
font-weight: 700;
font-size: 0.5rem;
color: #606060;
margin-top: 6px;
margin-bottom: 3px;
}
form div input {
border: 1px solid #ccc;
outline: none;
border-radius: none;
padding: 3px 5px;
width:300px;
}
form div input.error { border: 1px solid #f19e9e; }
form span {
display: none;
color: #f19e9e;
font-size: 0.6rem;
}
form span.error { display: block; }
form button {
display: block;
margin-top: 10px;
width: 100%;
padding: 5px 15px;
border: 1px solid #ccc;
}
</style>
</head>
<body>
<form
action=""
method="POST"
>
<div
class="<?= $formSubmittedSuccessfully ? "visible" : "" ?>"
>
<p>Form submitted successfully!</p>
</div>
<div>
<label for="first_name">First Name:</label>
<input
type="text"
id="first_name"
name="first_name"
placeholder="First name"
class="<?= array_key_exists("first_name", $errorMessages) ? "error" : "" ?>"
>
<span
class="<?= array_key_exists("first_name", $errorMessages) ? "error" : "" ?>"
>
<?= array_key_exists("first_name", $errorMessages) ? $errorMessages["first_name"] : "" ?>
</span>
</div>
<div>
<label for="last_name">Last Name:</label>
<input
type="text"
id="last_name"
name="last_name"
placeholder="Last name"
class="<?= array_key_exists("last_name", $errorMessages) ? "error" : "" ?>"
>
<span
class="<?= array_key_exists("last_name", $errorMessages) ? "error" : "" ?>"
>
<?= array_key_exists("last_name", $errorMessages) ? $errorMessages["last_name"] : "" ?>
</span>
</div>
<div>
<label for="email">Email:</label>
<input
type="email"
id="email"
name="email"
placeholder="user@example.com"
class="<?= array_key_exists("email", $errorMessages) ? "error" : "" ?>"
>
<span
class="<?= array_key_exists("email", $errorMessages) ? "error" : "" ?>"
>
<?= array_key_exists("email", $errorMessages) ? $errorMessages["email"] : "" ?>
</span>
</div>
<div>
<label for="password">Password:</label>
<input
type="password"
id="password"
name="password"
placeholder="secret"
class="<?= array_key_exists("password", $errorMessages) ? "error" : "" ?>"
>
<span
class="<?= array_key_exists("password", $errorMessages) ? "error" : "" ?>"
>
<?= array_key_exists("password", $errorMessages) ? $errorMessages["password"] : "" ?>
</span>
</div>
<div>
<label for="password_confirmation">Confirm Password:</label>
<input
type="password"
id="password_confirmation"
name="password_confirmation"
placeholder="secret"
class="<?= array_key_exists("password_confirmation", $errorMessages) ? "error" : "" ?>"
>
<span
class="<?= array_key_exists("password_confirmation", $errorMessages) ? "error" : "" ?>"
>
<?= array_key_exists("password_confirmation", $errorMessages) ? $errorMessages["password_confirmation"] : "" ?>
</span>
</div>
<button type="submit">Submit</button>
</form>
</body>
</html>