-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
50 lines (40 loc) · 1.32 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
<?php
require('user_validator.php');
if (isset($_POST['submit'])) {
//validate entries
$validation = new UserValidator($_POST);
$errors = $validation->validateForm();
//save data to db
}
?>
<!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>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Form Validation</h1>
<div class="new-user">
<h2>Create new user</h2>
<form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
<label for="username">UserName:</label>
<input type="text" name="username" id="username" value="<?php htmlspecialchars($_POST['username']) ?? '' ?>">
<div class="error">
<?php
echo $errors['username'] ?? '' ?>
</div>
<label for="email">Email:</label>
<input type="text" name="email" id="email" value="<?php htmlspecialchars($_POST['email']) ?? '' ?>">
<div class="error">
<?php
echo $errors['email'] ?? '' ?>
</div>
<input type="submit" value="submit" name="submit">
</form>
</div>
</body>
</html>