-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadminforgotpassword.php
118 lines (109 loc) · 4.71 KB
/
adminforgotpassword.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
109
110
111
112
113
114
115
116
117
118
<?php
require "assets/db.php";
require "assets/varnames.php";
require 'assets/sharedComponents.php';
$components = new SharedComponents();
$email = $email_err = $email_succ = "";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
// Check if email is empty
if (empty(trim($_POST["email"]))) {
$email_err = "Enter your Email.";
} else {
$email = trim($_POST["email"]);
}
if (empty($email_err))
{
$sql = "SELECT * FROM author WHERE author_email = :author_email";
if ($stmt = $pdo->prepare($sql))
{
$param_email = trim($_POST["email"]);
$stmt->bindParam(":author_email", $param_email, PDO::PARAM_STR);
if ($stmt->execute())
{
if ($stmt->rowCount() == 1)
{
if ($row = $stmt->fetch())
{
$set = 'EYO1BLUNT2AKAK3';
$code = substr(str_shuffle($set), 0, 12);
$bsql = "UPDATE author SET code=:code WHERE author_id=:author_id";
$stmt= $pdo->prepare($bsql);
$stmt->execute(['code' => $code, 'author_id' => $row["author_id"],]);
if ($stmt->rowCount())
{
$userid = $components->protect($row["author_id"]);
require 'assets/sendmail.php';
$model = new send_Mail();
$mailresult = $model->forgotpasswrd($_POST["email"], $row["author_fullname"], $code, $userid, "admin");
json_encode($mailresult);
if($mailresult["response"] == true)
$email_succ = $mailresult["message"];
else
$email_err = $mailresult["message"];
}
}
}
else
{
// Display an error message if username doesn't exist
$email_err = "No account found with that Email.";
}
}
else
{
echo "Oops! Something went wrong. Please try again later.";
}
unset($stmt);
}
}
unset($pdo);
}
include 'includes/header.php';
?>
<!--section-heading-->
<div class="section-heading " >
<div class="container-fluid">
<div class="section-heading-2">
<div class="row">
<div class="col-lg-12">
<div class="section-heading-2-title ">
<h1>Admin - Forgot Password</h1>
<p class="links"><a href="./">Home <i class="las la-angle-right"></i></a> Activate Account</p>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- display output-->
<section class="blog-author mt-30">
<div class="container-fluid">
<div class="">
<!--content-->
<div class="" style="justify-content: center; display: flex;">
<div class="row theiaStickySidebar">
<div class="card p-2">
<h3><span class="text-success"><?= $email_succ; ?></span></h3>
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" class="sign-form widget-form " method="POST">
<div class="form-group">
<input type="email" class="form-control <?= (!empty($email_err)) ? 'is-invalid' : ''; ?>" placeholder="Email*" name="email" value="">
<span class="invalid-feedback"><?= $email_err; ?></span>
</div>
<div class="form-group">
<button type="submit" class="btn-custom">Submit</button>
</div>
<p class="form-group text-center">Don't have an account? <a href="adminsignup.php" class="btn-link">Create One</a> </p>
</form>
</div>
</div>
<br>
</div>
<!--/-->
<br>
</div>
</div>
</section>
<?php
include 'includes/footer.php';
?>