-
Notifications
You must be signed in to change notification settings - Fork 1
/
dbUser.php
60 lines (41 loc) · 1.75 KB
/
dbUser.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
58
59
60
<?php
include("dbConnect.php");
// check if there is record match the input email and passowrd, return the record if valid
function checkLogin($email, $password) {
// Create connection with DB
$con = connectDB();
//$dbConnectInput["dc_sql"] = "SELECT * FROM users WHERE email = '" . $email . "' AND password='" . convert_uuencode($password) . "'";
$dbConnectInput["dc_sql"] = "SELECT * FROM users WHERE email = '" . $email . "' AND password='" . $password . "'";
$dbConnectInput["dc_sql_type"] = "select";
$dbConnectInput["dc_process_name"] = "";
$dbConnectOutput = excuteSql($con, $dbConnectInput);
mysql_close($con);
return $dbConnectOutput;
}
// check if there is record match the input user_id, return the record if valid
function getUserInfo($userId) {
// Create connection with DB
$con = connectDB();
$dbConnectInput["dc_sql"] = "SELECT * FROM users WHERE user_id = '" . $userId . "'";
$dbConnectInput["dc_sql_type"] = "select";
$dbConnectInput["dc_process_name"] = "";
$dbConnectOutput = excuteSql($con, $dbConnectInput);
mysql_close($con);
return $dbConnectOutput;
}
function updateUserInfo($userId, $email, $lastName, $firstName, $password) {
// Create connection with DB
$con = connectDB();
if ($password === "") {
$passStr = "";
} else {
$passStr = ", password = '" . $password . "'";
}
$dbConnectInput["dc_sql"] = "UPDATE users SET first_name='" . $firstName . "', last_name = '" . $lastName . "', email = '" . $email . "'" . $passStr . " WHERE user_id = '" . $userId . "'";
$dbConnectInput["dc_sql_type"] = "update";
$dbConnectInput["dc_process_name"] = "";
$dbConnectOutput = excuteSql($con, $dbConnectInput);
mysql_close($con);
return $dbConnectOutput;
}
?>