-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathforgot_password.php
110 lines (95 loc) · 5.83 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
<link type="text/css" rel="stylesheet" href="css/home.css" />
<?php
include_once 'includes/header.php';
include_once 'includes/footer.php';
?>
<html>
<head>
<title>
Forgot Password
</title>
</head>
<body>
<div id="container">
<?php
require_once 'mandrill-api-php/src/Mandrill.php';
$mandrill = new Mandrill('v5POumc7NJ7pBGRal5MeTw');
if(!loggedin()){
if(isset($_POST['email'])){
$email = $_POST['email'];
if(!empty($email)){
$query = "SELECT * FROM `student` WHERE `email`='".mysql_real_escape_string($email)."'";
if($query_run = mysql_query($query))
{
$query_num_rows = mysql_num_rows($query_run);
if($query_num_rows == 1){
$user_row = mysql_fetch_assoc($query_run);
$s_name = $user_row['s_name'];
$random = rand(11111, 99999);
$new_password = $random;
mysql_query("UPDATE student SET `password`='".mysql_real_escape_string($new_password)."' WHERE `email`='".$email."'");
$link = "Your new password is ".$new_password;
try {
$message = array(
'html' => '',
'text' => $link,
'subject' => 'Forgot Password',
'from_email' => '[email protected]',
'from_name' => 'NITH-Feedback',
'to' => array(
array(
'email' => $email,
'name' => $s_name,
'type' => 'to'
)
),
'headers' => array('Reply-To' => 'donotreply'),
'important' => false,
'track_opens' => null,
'track_clicks' => null,
'auto_text' => null,
'auto_html' => null,
'inline_css' => null,
'url_strip_qs' => null,
'preserve_recipients' => null,
'view_content_link' => null,
'tracking_domain' => null,
'signing_domain' => null,
'return_path_domain' => null,
'merge' => true
);
$async = false;
$ip_pool = 'Main Pool';
$send_at = 'example send_at';
$result = $mandrill->messages->send($message, $async, $ip_pool);
//print_r($result);
echo '<br /><center>Your new password has been emailed to you.<center>';
die();
} catch(Mandrill_Error $e) {
//echo 'A mandrill error occurred: ' . get_class($e) . ' - ' . $e->getMessage();
throw $e;
echo '<br /><center>Email not sent.</center>';
}
}
else{
echo '<br /><center>E-mail does not exist.</center>';
}
}
}
else
echo '<br /><center><span style="color:red;">*You must enter an E-mail.</span><center>';
}
}
else{
header('Location: index.php');
}
?>
<br /><center>
<form action="<?php echo htmlspecialchars($current_file); ?>" method="post">
E-mail :<input type="email" name="email" />
<input type="submit" value="Submit"></input>
</form>
</center>
</div>
</body>
</html>