-
Notifications
You must be signed in to change notification settings - Fork 2
/
sendpasswordreset.php
33 lines (27 loc) · 973 Bytes
/
sendpasswordreset.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
<?php
include_once 'functions.php';
$conn=opendb();
$email = sanitise('email', 'p');
$query = "SELECT * FROM users WHERE Email='$email'";
$result = mysql_query($query) or die(mysql_error());
if(mysql_num_rows($result)==1){
$row=mysql_fetch_assoc($result);
if($row['Validated']==1) {
if($row['ResetKey']==NULL||time()>$row['ResetTimeout']){
$resetkey = sha1(generatesalt(64));
$timeout = time() + 604800; //One Week
$UserID = $row['UserID'];
$query = "UPDATE users SET ResetKey='$resetkey', ResetTimeout='$timeout' WHERE Email='$email'";
$result = mysql_query($query) or die(mysql_error());
sendpasswordreset($email, $resetkey, $UserID);
echo "email: ".$email." resetkey: ".$resetkey." UserID: ".$UserID;
} else {
echo "You've already tried to reset";
}
} else {
echo "You haven't validated your account yet! Check your emails, including the spam folder";
}
} else {
echo "your email wasn't found :(";
}
?>