-
Notifications
You must be signed in to change notification settings - Fork 28
/
otp.php
27 lines (18 loc) · 838 Bytes
/
otp.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
<?php
include('DB.php');
if (isset($_POST['login'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$otp = rand(1000000000,9999999999);
if (DB::query('SELECT username FROM users WHERE username=:username', array(':username'=>$username))) {
if (password_verify($password, DB::query('SELECT password FROM users WHERE username=:username', array(':username'=>$username))[0]['password'])) {
echo 'Correct';
DB::query('UPDATE users SET password=:password WHERE username=:username', array(':username'=>$username, ':password'=>password_hash($otp, PASSWORD_BCRYPT)));
} else {
echo 'WRONG!';
}
} else {
echo 'FAKE USER!';
}
}
?>