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
/
forgotPassword.php
executable file
·108 lines (93 loc) · 3.88 KB
/
forgotPassword.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
108
<?php
session_start();
require_once('essentials/config.php');
include "dbConfig.php";
if (isset($_SESSION['email'])) : {
header("location: index.php");
}
endif;
$validation = new validation;
$queries = new queries;
$sendEmail = new sendEmail;
if (isset($_POST['submit'])) {
$validation->validate('email', 'Email', 'required|min_len|6');
if ($validation->run()) {
$email = $validation->input('email');
$fullName = "User";
$code = rand();
$code = password_hash($code, PASSWORD_DEFAULT);
$url = "https://" . $_SERVER['SERVER_NAME'] . "/aanav/verifyPassword.php?code=" . $code;
$url2 = "https://" . $_SERVER['SERVER_NAME'] . "/aanav/contact.php";
$status = 0;
$subject = 'Please verify it is you';
$body = '<p style="color:#66FCF1; font-size: 32px;" > Hi ' . $fullName . '</p><p style="color:grey; font-size: 16px;" > You are almost done.Click below to set a new password</p>
<p><a style="background-color: #66FCF1;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
-webkit-transition-duration: 0.4s;
transition-duration: 0.4s;"
href="' . $url . '">Change Password</a></p><p style="color:red; font-size: 10px;" > Need Help ? <a href="' . $url2 . '">Contact Us</a></p>';
$result = mysqli_query($connect,"UPDATE customer SET code='$code' WHERE email = '$email' AND status<=1 ");
if ( $result) {
if ($sendEmail->send($fullName, $email, $subject, $body)) {
$_SESSION['accountCreated'] = " Please check your inbox to set new password";
header("location: login.php");
}
} else {
$_SESSION['notActive'] = "Account doesn't exist";
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>Forgot Password</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">
<div class="brand-wrapper">
<img src="img/logo_nav.png" alt="logo" class="logo">
</div>
<div class="login-wrapper my-auto">
<h1 class="login-title">Hi there</h1>
<form name="signupform" method="post">
<div class="form-group mb-6">
<label for="email">Enter Your Registered Email</label>
<input type="email" name="email" class="form-control" placeholder="[email protected]" required />
<div class="error text-center text-danger">
<?php if (!empty($validation->errors['email'])) : echo $validation->errors['email'];
endif; ?>
</div>
</div>
<input name="submit" id="login" class="btn btn-block login-btn" type="submit" value="Change Password">
</form>
<p class="login-wrapper-footer-text">Already a customer <a href="login.php" class="text-reset">Welcome Back</a></p>
</div>
</div>
</div>
</div>
</main>
<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</body>
</html>