-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathchangepassprocess.php
77 lines (47 loc) · 1.42 KB
/
changepassprocess.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
<?php
$password_error = $Repassword_error = $DB_error ="";
$password = $Repassword = "";
$conn = new mysqli('localhost','root','','messaging system');
if($conn->connect_error) {
$DB_error ="database connection error!";
} else{
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//password validation
if (empty($_POST["Password"])) {
$password_error = "you must enter a password ! ";
} else {
$password= test_input($_POST["Password"]);
if (!preg_match("/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$/",$password)) {
$password_error = "Invalid password ! ";
}
}
if (empty($_POST["Repassword"])) {
$Repassword_error = "you must enter a password !";
}
//matching passwords !
if($Repassword_error == "" && $password_error == "" ) {
if($_POST['Password'] != $_POST['Repassword']){
$password_error = "passwords do not match !!";
}else{
$password= test_input($_POST["Password"]);
$ID = 17 ;
if ($stmt = $conn->prepare("UPDATE user SET Password =? WHERE UserID = ?")){
$stmt->bind_param('sd', $password, $ID);
$stmt->execute();
$stmt->close();
$DB_error =" yaaaaaaaaah!";
}
else {
$DB_error =" fuck errors!";
}
}
}
}
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>