-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauth.php
57 lines (54 loc) · 1.64 KB
/
auth.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
require_once('./config.php');
$username = $_POST['username'];
$member_no = $_POST['member_no'];
if(!isset($_SESSION['page']))
$_SESSION['page'] = 'index.php';
if(!$username && !$member_no){
header('Location: login.php');
exit();
}
$next_page = $_SESSION['page'];
$users = array();
// global $tblUsers;
if(!empty($username)){
$query = "SELECT * FROM {$tblUsers} WHERE username = '{$username}'";
$result = $db->query($query);
$user = mysqli_num_rows($result);
if($user) {
$sql = "select username, ID, staff from {$tblUsers} where username = '{$username}'";
$result =$db->query($sql);
$res = mysqli_fetch_assoc($result);
$user_info = array(
'username' => $res['username'],
'user_id' => $res['ID'],
'staff' => $res['staff'],
);
$_SESSION['user'] = $user_info;
}
} else {
$query = "SELECT * FROM {$tblUsers} WHERE staff = '{$member_no}'";
$result = $db->query($query);
$user = mysqli_num_rows($result);
if($user) {
$sql = "select username, ID, staff from {$tblUsers} where staff = '{$member_no}'";
$result =$db->query($sql);
$res = mysqli_fetch_assoc($result);
$user_info = array(
'username' => $res['username'],
'user_id' => $res['ID'],
'staff' => $res['staff'],
);
$_SESSION['user'] = $user_info;
}
}
if($next_page == 'stocking_input.php') {
if(!isset($_SESSION['stocking_action']))
header('Location: stocking_select_action.php');
else
header('Location: '.$next_page);
} else {
header('Location: '.$next_page);
}
exit();
?>