-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadmin-password-reset.php
74 lines (69 loc) · 2.41 KB
/
admin-password-reset.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
<?php
session_start();
if (isset($_SESSION['id'])) {
include './admin-header.php';
include './connection.php';
$err= '';
if (isset($_GET['id'])) {
$user_id = $_GET['id'];
if (isset($_POST['reset'])) {
$password = $_POST['password'];
$repassword = $_POST['repassword'];
if ($password == $repassword) {
print $err;
if (strlen($password) < 8 || strlen($password) > 16) {
$err = 'password must be of lenght between 8-16';
} elseif (!preg_match ("/[0-9]/", $password)) {
$err = 'password must contain at least one number';
} elseif (!preg_match("/[a-z]/", $password)) {
$err = 'password must contain one small case letter';
} elseif (!preg_match("/[A-Z]/", $password)) {
$err = 'password must contain at least one capital letter';
} elseif (!preg_match("/[!@#%$]/", $password)) {
$err = 'password must have either of !, @, #, %, $';
} else {
$err ='nice password';
$password = md5($password);
$insertQuery = "UPDATE registeration SET password= '$password' WHERE user_id = '$user_id'";
$insert = $con -> query($insertQuery);
if ($insert) {
$err = 'password updated';
} else {
$err = 'Oh snap! something went wrong';
}
}
}
}
} else {
header('location: ./admin.php');
exit;
}
} else {
header('location: ./index.php');
}
?>
<div class="container">
<form method="POST" class="s 12">
<div class="row">
<div class="input-field col s6">
<input id="password" type="password" class="validate" name="password" required>
<label for="password">Password</label>
</div>
<div class="input-field col s6">
<input id="repassword" type="password" class="validate" name="repassword" required>
<label for="repassword">Re enter password</label>
</div>
</div>
<div class="row">
<div class="center">
<input type="submit" value="Submit" class="input-field btn" name="reset">
<?php
echo "<br>";
echo $err;
?>
</div>
</div>
</form>
</div>
<!-- Compiled and minified JavaScript -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>