forked from Lokesh-Anand/HospitalManagement
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreset.php
More file actions
84 lines (64 loc) · 2.34 KB
/
reset.php
File metadata and controls
84 lines (64 loc) · 2.34 KB
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
<?php
require("common.php");
require("PHPMailer/PHPMailerAutoload.php");
if (isset($_POST['email'])){
$query="select * from users where email=:email";
$query_params = array(
':email' => $_POST['email']
);
try
{
// Execute the query against the database
$stmt = $db->prepare($query);
$result = $stmt->execute($query_params);
}
catch(PDOException $ex)
{
die("Failed to run query: " . $ex->getMessage());
}
$row = $stmt->fetch();
if($row)
{
$pass = $row['password'];//FETCHING PASS
$to = $row['email'];
$body = "<b>password recovery Script<b></br>
-----------------------------------------------</br>
<p>Visit the link to recover your password</p>
<p>Url : https://www.hospital.dev/resetlink.php</br></p>
<p>Sincerely,Our Hospital</p>";
$Mail = new PHPMailer();
$Mail->IsSMTP(); // Use SMTP
$Mail->Host = "smtp.gmail.com"; // Sets SMTP server for gmail
$Mail->SMTPDebug = 0; // 2 to enable SMTP debug information
$Mail->SMTPAuth = TRUE; // enable SMTP authentication
$Mail->SMTPSecure = "tls"; //Secure conection
$Mail->Port = 587; // set the SMTP port to gmail's port
$Mail->Username = 'lokesha805'; // gmail account username
$Mail->Password = '4rfv5tgb6yhn'; // gmail account password
$Mail->Priority = 1; // Highest priority - Email priority (1 = High, 3 = Normal, 5 = low)
$Mail->CharSet = 'UTF-8';
$Mail->Encoding = '8bit';
$Mail->Subject = 'Password Recovery';
$Mail->ContentType = 'text/html; charset=utf-8\r\n';
$Mail->From = 'lokesha805@gmail.com'; //Your email adress (Gmail overwrites it anyway)
$Mail->FromName = 'lokesh';
$Mail->WordWrap = 900; // RFC 2822 Compliant for Max 998 characters per line
$Mail->addAddress($to); // To
$Mail->isHTML( TRUE );
$Mail->Body = $body;
$Mail->AltBody = 'This is a recovery mail';
$_SESSION['user1'] = $row;
if(!$Mail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $Mail->ErrorInfo;
exit;
}
$Mail->SmtpClose();
echo 'Message has been sent';
}
else {
echo "<span style='color:#ff0000;'> Not found your email in our database</span>";
}
//If the message is sent successfully, display sucess message otherwise display an error message.
}
?>