-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgotten-password2.php
100 lines (90 loc) · 3.3 KB
/
forgotten-password2.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
session_start();
if(!isset($_SESSION['email'])){
header("location: login.php");
}
require "header.php";
require "database/connection.php";
if(isset($_SESSION['email'])){
$email = $_SESSION['email'];
}
$sql = "SELECT * FROM users WHERE email=?";
$stmt = $conn->prepare($sql);
$stmt->bind_param('s', $email);
if($stmt->execute()){
$result = $stmt->get_result();
if($result->num_rows > 0){
$row = $result->fetch_assoc();
}
}
?>
<body>
<section class="container-fluid login-wrapper pt-5">
<div class="container">
<div class="row justify-content-center">
<div class="col-lg-6">
<div class="login-form">
<a href="javascript:history.back();" style="font-size: 1.4rem;"><i class="bi bi-arrow-left" style="margin-right: .5rem;"></i> Change Password</a>
<img src="assets/img/easylearn/logo-cut.png" style="border-radius: 5px; width: 4rem; height: 4rem; margin-left: 8.5rem;" alt="">
<h2 class="pt-5" style="font-size: 2rem; line-height: 1.3;">Enter a More Secured Password?</h2>
<form id="status_form">
<div class="input-group mb-5">
<input type="password" class="form-control" name="password" id="password" placeholder="Enter Password">
</div>
<div class="input-group mb-5">
<input type="password" class="form-control" name="confirm_password" id="confirm_password" placeholder="Confirm Password">
</div>
<input type="hidden" id="user_id" value="<?= $email; ?>">
<div class="form-group">
<button type="submit" id="status_btn" class="form-control getStarted-btn">Continue</button>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<?php require "footer.php"; ?>
<script>
$(document).on('click', '#status_btn', function(e){
e.preventDefault();
var password = $('#password').val();
var confirm_password = $('#confirm_password').val();
var user_id = $('#user_id').val();
if(password == "" || confirm_password == ""){
Swal.fire(
'Invalid',
'No field should be empty',
'error'
)
} else if(password.length < 6){
Swal.fire(
'Invalid',
'Password must be greater than 6',
'error'
)
} else if(password !== confirm_password){
Swal.fire(
'Invalid',
'Password does not match',
'error'
)
}
else {
$.ajax({
url: 'backend/forgotten-password2.php',
type: 'post',
data:
{
password: password,
confirm_password: confirm_password,
user_id:user_id
},
success: function(response){
location.href = 'login.php';
}
});
$('#status_form')[0].reset();
}
});
</script>