-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathuser.php
More file actions
81 lines (53 loc) · 1.63 KB
/
Copy pathuser.php
File metadata and controls
81 lines (53 loc) · 1.63 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
include('database.php');
session_start();
class user{
var $username;
var $userid;
var $password;
var $type;
public function login($userid,$password){
$db=new database();
$valid=$db->validateCredentials($userid,$password);
if($valid){
$row=mysqli_fetch_row($valid);
echo $row;
$_SESSION["name"] = $row[3];
$_SESSION["userid"] = $row[0];
$_SESSION["password"] = $row[1];
$_SESSION["type"] = $row[2];
if($_SESSION["type"]=="student"){
header('Location:studenthome.php');
}
if($_SESSION["type"]=="admin"){
header('Location:adminhome.php');
}
if($_SESSION["type"]=="faculty"){
header('Location:facultyhome.php');
}
}
else{
echo"<script>alert('invalid userid or password')</script>";
//header('Location:login.php');
return;
}
}
function logout (){
session_unset();
session_destroy();
header('Location:login.php');
}
function getLoginId(){
return $this->userid;
}
function getUserName(){
return $this->username;
}
function setUserName($name){
$this->username=$name;
}
function setLoginId($id){
$this->userid=$id;
}
}
?>