-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathforgot-password.php
34 lines (29 loc) · 1.07 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
<?php
include ('./classes/DB.php');
if(isset($_POST['resetpassword'])){
$email=$_POST['email'];
$cstrong=true;
$token = bin2hex(openssl_random_pseudo_bytes(64,$cstrong));
$user_id=DB::query('SELECT id FROM users WHERE email=:email',array(':email'=>$email))[0]['id'];
DB::query('INSERT INTO password_tokens (token, user_id) VALUES (:token, :user_id)',array(':token'=>sha1($token),':user_id'=>$user_id));
echo "email sent<br>";
$url="Location: /SushiNetwork/change-password.php?token=".$token."";
header($url); // new page
}
?>
<html>
<head>
<title>SSN:Change Acc Pass</title>
<link rel="stylesheet" href="CSS/style.css">
<meta charset="utf-8">
</head>
<body>
<div class="logForm">
<h1>Forgot your account Pass</h1>
<form action="forgot-password.php" method="post">
<input type="email" name="email" placeholder="[email protected]">
<input type="submit" name="resetpassword" value="Reset Password">
</form>
</div>
</body>
</html>