-
Notifications
You must be signed in to change notification settings - Fork 0
/
login.php
37 lines (34 loc) · 1.09 KB
/
login.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
<?php
//Start session
session_start();
include( 'db.php' );
if (isset($_POST['login'])) {
//Set the POST values
$email = isset($_POST['email'])? $_POST['email']: '';
$password = isset($_POST['password'])? $_POST['password']: '';
//Create query
$userQ = $conn->prepare("SELECT * FROM `fnfcustomer` WHERE `email` = '$email' && `password` = '$password'");
$userQ->execute();
$user_count = $userQ->rowcount();
//Check whether the query was successful or not
if( $user_count > 0 ){
$userInfo = $userQ->fetch();
$_SESSION['uid'] = $userInfo['customer_id'];
$_SESSION['first_name'] = $userInfo['first_name'];
$_SESSION['last_name'] = $userInfo['last_name'];
$_SESSION['email'] = $userInfo['email'];
$_SESSION['phone'] = $userInfo['phone'];
$_SESSION['address'] = $userInfo['address'];
$_SESSION['loggedin'] = TRUE;
$_SESSION ['cart'] = '';
$_SESSION ['access'] = $userInfo['access'];
if( $_SESSION ['access'] > '0' ){
header("Location: admin/door.php");
} else {
header("Location: index.php");
}
} else {
header("Location: index.php?p");
}
}
?>