-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpass1.php
More file actions
83 lines (68 loc) · 2.08 KB
/
pass1.php
File metadata and controls
83 lines (68 loc) · 2.08 KB
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
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Retrieving the user input and storing it in the variable
$passcheck = $_POST["passcheck"];
// Printing the value of the password variable
class PasswordChecker {
public $passcheck;
public function __construct($passcheck) {
$this->passcheck = $passcheck;
}
public function checker() {
$strength = 0;
// check length of password
if (strlen($this->passcheck) >= 8) {
$strength += 30;
}elseif(strlen($this->passcheck >= 6)) {
$strength += 10;
}
// check for uppercase letters
if (preg_match('/[A-Z]/', $this->passcheck)) {
$strength += 20;
}
// check for lowercase letters
if(preg_match('/[a-z]/', $this->passcheck)) {
$strength += 20;
}
// chck for numbers
if(preg_match('/\d/', $this->passcheck)) {
$strength += 20;
}
// check for special characters
if (preg_match('/[^A-Za-z0-9]/', $this->passcheck)) {
$strength += 10;
}
// return result
return 'Password Strength: '.$strength. '%';
}
}
$passwordChecker = new PasswordChecker($passcheck);
echo $passwordChecker->checker();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>checker</title>
<link rel="stylesheet" href="style.css">
</head>
<body bgcolor="lightblue">
<div class="wrapper">
<div class="title">
<h1>Type your password below</h1>
</div>
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<div class="contact-form">
<div class="input-fields">
<input type="password" id="passcheck" name="passcheck">
</div>
<div class="msg">
<button type="submit" class="btn"> Check Strength </button>
</div>
</div>
</div>
</form>
<center><a href="index.html">Log Out</a>
</body>
</html>