-
Notifications
You must be signed in to change notification settings - Fork 0
/
forgot_password.php
131 lines (117 loc) · 4.98 KB
/
forgot_password.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
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
//Import PHPMailer classes into the global namespace
//These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'PHPMailer/src/Exception.php';
require 'PHPMailer/src/PHPMailer.php';
require 'PHPMailer/src/SMTP.php';
require 'config.php';
//Create an instance; passing `true` enables exceptions
if(isset($_POST["useremail"])){
$emailTo=$_POST["useremail"];
$code = uniqid(true);
$query= mysqli_query($conn,"INSERT INTO resetpassword(code,email) VALUES('$code','$emailTo')");
if(!$query){
exit("Something went wrong.");
}
$mail = new PHPMailer(true);
try {
//Server settings
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.gmail.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = '[email protected]'; //SMTP username
$mail->Password = 'Pro@World811'; //SMTP password
$mail->SMTPSecure = 'tsl'; //Enable implicit TLS encryption
$mail->Port = 587; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('[email protected]', 'AtoZ Organics');
$mail->addAddress("$emailTo"); //Name is optional
$mail->addReplyTo('[email protected]', 'No reply');
//Content
$url = "http://".$_SERVER["HTTP_HOST"].dirname($_SERVER["PHP_SELF"])."/resetpassword.php?code=$code";
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Your Password reset link';
$mail->Body = "Click <a href='$url'>here</a>to reset your password.</b>";
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$mail->send();
echo 'Email has been sent successfully.';
} catch (Exception $e) {
echo "Email could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Forget password</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;500;600;700&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
<div class="navbar">
<div class="logo">
<a href="index.php"><img src="images/logo.png" width ="125px"></a>
</div>
<nav>
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="product.php">Products</a></li>
<li><a href="aboutus.php">About</a></li>
<li><a href="contact.php">Contact</a></li>
<li><a href="login.php">Seller Account</a></li>
</ul>
</nav>
<img src="images/cart.png" width="30px" height="30px">
</div>
</div>
<div class="account-page">
<div class="container">
<div class="row">
<div class="col-2">
<img src="images/organic_1.jpg" width="100%">
</div>
<div class="col-2">
<div class="form-container">
<div class="form-btn">
<span>Reset your Password!</span>
</div>
<form action="" method="post">
<p>Enter your e-mail address:</p>
<input type="text" placeholder="Email" name="useremail" required>
<button name="reset" class="btn">Reset Password</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!------------------------------------footer-------------------------------->
<div class="footer">
<div class="container">
<div class="row">
<div class="footer-col">
<h3>Follow Us On</h3>
<ul>
<li>
<a href=""><img src="https://img.icons8.com/fluent/50/000000/facebook-new.png"/></a>
</li>
<li>
<a href=""><img src="https://img.icons8.com/fluent/48/000000/instagram-new.png"/></a>
</li>
<li>
<a href=""><img src="https://img.icons8.com/fluent/48/000000/twitter.png"/></a>
</li>
</ul>
</div>
</div>
</div>
<div class="copyright"><p>All rights reserved.</p></div>
</div>
</body>
</html>