-
Notifications
You must be signed in to change notification settings - Fork 0
/
authentication.php
42 lines (35 loc) · 1.18 KB
/
authentication.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
35
36
37
38
39
40
41
42
<?php
session_start();
$DATABASE_HOST = 'localhost';
$DATABASE_USER = 'Fiber_User';
$DATABASE_PASS = 'anonymousfiber';
$DATABASE_NAME = 'Anonymous_Fiber';
$con = mysqli_connect($DATABASE_HOST, $DATABASE_USER, $DATABASE_PASS, $DATABASE_NAME);
if ( mysqli_connect_errno() ) {
exit('Failed to connect to MySQL: ' . mysqli_connect_error());
}
if ( !isset($_POST['email'], $_POST['password']) ) {
exit('Please fill both the email and password fields!');
}
if ($stmt = $con->prepare('SELECT Customer_ID, password FROM user WHERE email = ?')) {
$stmt->bind_param('s', $_POST['email']);
$stmt->execute();
$stmt->store_result();
if ($stmt->num_rows > 0) {
$stmt->bind_result($Customer_ID, $password);
$stmt->fetch();
if (password_verify($_POST['password'], $password)) {
session_regenerate_id();
$_SESSION['loggedin'] = TRUE;
$_SESSION['name'] = $_POST['email'];
$_SESSION['Customer_ID'] = $Customer_ID;
header('Location: profilepage.php');
} else {
echo 'Incorrect email and/or password!';
}
} else {
echo 'Incorrect email and/or password!';
}
$stmt->close();
}
?>