-
Notifications
You must be signed in to change notification settings - Fork 3
/
log-action.php
28 lines (28 loc) · 776 Bytes
/
log-action.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
<?php
if (isset($_POST['auth'])) {
require 'db.php';
$email = $_POST['email'];
$password = $_POST['password'];
$stmt = "SELECT * FROM users WHERE email = ?";
$prep = $conn->prepare($stmt);
$prep->execute([$email]);
$result = $prep->fetch();
if (!empty($result)) {
$user_id = $result['user_id'];
$dbpassword = $result['password'];
$username = $result['username'];
if (password_verify($password, $dbpassword)) {
setcookie('auth', $user_id, time() + 86400 * 30, '/');
setcookie('mailer', $email, time() + 86400 * 30, '/');
setcookie('username', $username, time() + 86400 * 30, '/');
echo "Authorized";
}
else{
echo "Incorrect password";
}
}
else{
echo "Account doesn't exists";
}
}
?>