-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkuser.php
53 lines (49 loc) · 1.55 KB
/
checkuser.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
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
include "class/connect.class.php";
$con = new getConnection();
$db = $con->PDO();
// if(!isset($_SESSION['username'])){
// if(isset($_POST['check'])){
$success = 0;
$username = $_POST['username'];
$p = $_POST['password'];
$password = md5($p);
$query = $db->query("SELECT * FROM tbl_users a
LEFT OUTER JOIN tbl_user_groups b ON a.Type = b.groupId
WHERE a.Username = '$username' AND a.Password = '$password' AND a.Status = true");
if($query->rowCount() > 0){
$ipaddress = getenv('REMOTE_ADDR');
$row = $query->fetch(PDO::FETCH_ASSOC);
$fname = strtoupper($row['First_name']);
$mname = strtoupper($row['Mid_name'][0].".");
$lname = strtoupper($row['Last_name']);
$department =$row['Department'];
$type=$row['groupName'];
$name = $fname." ".$mname." ".$lname;
$active_user ="$lname, $fname";
$branch = $row['Branch'];
$mun = $row["Municipality"];
$area = ($row["area"] == NULL ? "1" : $row["area"]);
$RequestorID = $row['id'];
if($type!='Encoder'){
$_SESSION['username']=$username;
$_SESSION['usertype']=strtolower($type);
$_SESSION['name']=$name;
$_SESSION['reviewer']='';
$_SESSION['supervisor']='';
$_SESSION['active_user']=$active_user;
$_SESSION['branch']=$branch;
$_SESSION['userId']=$RequestorID;
$_SESSION["mun"] = $mun;
$_SESSION["area"] = $area;
$success=1;
} else{
$_SESSION['branch']=$branch;
$success=0;
}
echo $success;
}
// }
// }
?>