-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPasswordReset.php
More file actions
51 lines (39 loc) · 1.43 KB
/
PasswordReset.php
File metadata and controls
51 lines (39 loc) · 1.43 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
<?php require_once('Connection.php'); ?>
<?php require_once("Functions.php"); ?>
<?php include("Header.php"); ?>
<?php
$message = "";
$Login = false;
if (isset($_POST['submit'])) { // Form has been submitted.
// form data
$mail = trim(mysql_prep($_POST['mail']));
if(!empty($mail)) {
$reset_link = generate_salt(64);
$mysql_query = "UPDATE `user` SET `passwordResetLink`='" . $reset_link . "' WHERE `mail`='" . $mail . "'";
$result = mysql_query($mysql_query, $connection);
if($result) {
// Reset link opdateret
send_mail($mail, "Password reset", "Reset link below \n http://www.319.dk/JBID/PasswordResetNew.php?mail=" . $mail . "&key=" . $reset_link);
$Login = true;
echo "<h1>E-mail sent</h1>";
} else {
// Fejl med databasen detaljer kan ses ved brug af "mysql_error()"
$message = "Unknown error";
}
} else {
// mail ikke god nok
$message = "E-mail to short";
}
}
if (!$Login) {
echo '<h1>Reset password for JBiD</h1>
<h3>Password Reset - Got here by accident? Go to <a href="index.html">login</a></h3>
<form method="post">
<p id="error">' . $message . '</p>
<p>Please enter the email you used to sign up</p>
<input id="mail" type="email" required autofocus name="mail">
<input id="createButton" type="submit" value="Send reset email" name="submit">
</form>';
}
?>
<?php include("Footer.php"); ?>