This repository has been archived by the owner on Apr 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verifyPassword.php
executable file
·107 lines (99 loc) · 3.88 KB
/
verifyPassword.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
101
102
103
104
105
106
107
<?php
session_start();
require_once('essentials/config.php');
include "dbConfig.php";
if (isset($_SESSION['email'])) : {
header("location: index.php");
}
endif;
if(isset($_GET['code']) && $_GET['code'] != '0'){
$code = $_GET['code'];
$verify = mysqli_query($connect, "SELECT * FROM customer WHERE code='$code' and status <= 1");
if (mysqli_num_rows($verify) < 1) {
$_SESSION['notActive'] = "Some error occured";
header('location: login.php');
}
}
else
{
$_SESSION['notActive'] = "Some error occured";
header('location: login.php');
}
$validation = new validation;
$queries = new queries;
if (isset($_POST['submit'])) {
$validation->validate('newpass', 'New Password', 'required|min_len|6');
$validation->validate('cnfrmpass', 'Confirm Password', 'required|min_len|6');
if ($validation->run()) {
$newpass = $validation->input('newpass');
$cnfrmpass = $validation->input('cnfrmpass');
if ($newpass == $cnfrmpass) {
$newpass = password_hash($newpass, PASSWORD_DEFAULT);
$update = mysqli_query($connect, "UPDATE customer SET password = '$newpass' WHERE code='$code' ");
if ($update){
$deleteCode = mysqli_query($connect, "UPDATE customer SET code = 0 WHERE code='$code' ");
$_SESSION['emailVerified'] = "Your password has been changed successfully";
header("location:login.php");
}
else
{
$_SESSION['notActive'] = "New and confirm password doesn't match";
header("location: login.php");
}
}
}
else{
$_SESSION['notActive'] = "Some error occured";
header('location: login.php');
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Login</title>
<link href="https://fonts.googleapis.com/css?family=Karla:400,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.materialdesignicons.com/4.8.95/css/materialdesignicons.min.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<link rel="stylesheet" href="css/login.css">
</head>
<body>
<main>
<div class="container-fluid">
<div class="row">
<div class="col-sm-6 login-section-wrapper">
<?php if (isset($_SESSION['unmatched'])) : ?>
<div class="alert alert-danger">
<?php echo $_SESSION['unmatched']; ?>
</div>
<?php endif; ?>
<?php unset($_SESSION['unmatched']); ?>
<div class="login-wrapper my-auto">
<h1 class="login-title">Set New Password</h1>
<form method="post" action="">
<div class="form-group mb-4">
<label for="newpass">New Password</label>
<input type="password" name="newpass" id="newpass" class="form-control" placeholder="********" required />
<div class="error text-danger text-center">
<?php if (!empty($validation->errors['newpass'])) : echo $validation->errors['newpass'];
endif; ?>
</div>
</div>
<div class="form-group mb-4">
<label for="cnfrmpass">Confirm Password</label>
<input type="password" name="cnfrmpass" id="cnfrmpass" class="form-control" placeholder="********" required />
<div class="error text-danger text-center">
<?php if (!empty($validation->errors['cnfrmpass'])) : echo $validation->errors['cnfrmpass'];
endif; ?>
</div>
</div>
<input name="submit" id="login" class="btn btn-block login-btn" type="submit" value="Proceed">
</form>
</div>
</div>
</div>
</div>
</main>