-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsgnup.php
43 lines (38 loc) · 1.14 KB
/
sgnup.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Signup form</title>
<style>
#error{
colour: red;
}
</style>
</head>
<body>
<?php
$fname = "";
$fnameErr = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["fname"])) {
$fnameErr = "Name is required";
} else {
$fname = test_input($_POST["fname"]);
// check if name only contains letters and whitespace
if (!preg_match("/^[a-zA-Z ]*$/",$fname)) {
$fnameErr = "Only letters and white space allowed";
}
}
}
?>
<div>
<form name="signupform" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<label for="fname">First name : </label>
<input type="text" name="fname" placeholder="First name">
<input type="submit" value="Sign up" onclick="showfname()"><span id="error"><?php echo $fnameErr; ?></span>
</form>
</div>
</body>
</html>