-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
85 lines (73 loc) · 2.48 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
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$username = $_REQUEST["username"];
$password = $_REQUEST["password"];
$username_count = strlen($username);
$password_count = strlen($password);
$x = false;
if($username_count>7){
echo "username tidak boleh lebih dari 7 karakter atau huruf<br>";
$x = true;
}
if ($username == "") {
echo "username tidak boleh kosong<br>";
$x = true;
}
if ($password == "") {
echo "password tidak boleh kosong<br>";
$x = true;
}
if (!preg_match("/[A-Z]/", $password) ) {
echo "password harus menggunakan huruf kapital<br>";
$x = true;
}
if (!preg_match("/[a-z]/", $password)) {
echo "password harus menggunakan huruf kecil<br>";
$x = true;
}
if (!preg_match("/[^a-zA-Z\d]/", $password)) {
echo "password harus menggunakan karakter spesial<br>";
$x = true;
}
if (!preg_match("/[0-9]/", $password)) {
echo "password harus menggunakan digit angka<br>";
$x = true;
}
if($password_count<10){
echo "password harus lebih dari 10 karakter<br>";
$x = true;
}
if( $x == false ){
echo "berhasil";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tugas Modul 2</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table>
<tr>
<td>Username</td>
<td>:</td>
<td><input type="text" name="username" id="username"></td>
</tr>
<tr>
<td>Password</td>
<td>:</td>
<td><input type="text" name="password" id="password"></td>
</tr>
<tr>
<td></td>
<td></td>
<td><button type="submit">Submit</button></td>
</tr>
</table>
</form>
</body>
</html>