forked from agmip/ace-dssat-import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkUserInfo.php
51 lines (40 loc) · 1.28 KB
/
checkUserInfo.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
<?php
session_start();
// if (!isset($_SESSION["user"])) {
// Header("Location: login.php?" . SID);
// }
include("dbUser.php");
$email = $_POST["email"];
$password = $_POST["password"];
$dbConnectOutput = checkLogin($email, $password);
// check if the input data is valid
if ($dbConnectOutput["dc_result_num"] === 1) {
$lastName = $dbConnectOutput["dc_result"][0]["last_name"];
$firstName = $dbConnectOutput["dc_result"][0]["first_name"];
$userId = $dbConnectOutput["dc_result"][0]["user_id"];
}
// Check if the input info is same to the data in DB
if (isset($lastName) && isset($firstName)) {
// set user name into session
$_SESSION["user"] = $userId;
$_SESSION["user_last_name"] = $lastName;
$_SESSION["user_first_name"] = $firstName;
} else {
// Login error msg set into session
$_SESSION["errFlg"] = "001";
Header("Location: login.php?" . SID );
exit();
}
// Check if the password is blank which means it needs user to fill the whole personal info
if ($password === "" || $lastName === "") {
// Go to userInfo page
$_SESSION["user_last_name"] = $email;
$_SESSION["user_first_name"] = "";
Header("Location: userInfo.php?" . SID);
exit();
} else {
// ALL OK, go to menu page
Header("Location: menu.php?" . SID);
exit();
}
?>