-
Notifications
You must be signed in to change notification settings - Fork 3
/
login.php
108 lines (106 loc) · 2.86 KB
/
login.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
$dbhost = 'localhost:3306';
$dbuser = 'root';
$dbpass = '';
$conn = mysqli_connect($dbhost, $dbuser, $dbpass);
if(! $conn ) {
die('Could not connect: ' . mysqli_error());
}
$select_db = mysqli_select_db($conn,'interns');
if(! $select_db)
{
die("database connection failed".mysqli_error($conn));
}
$id_1=0;
$name_2=0;
if(isset($_POST['register']))
{
$myuserid=$_POST['userid'];
$mypassword=$_POST['password'];
$my_position=$_POST['position'];
$sql="SELECT user_id from user where user_id='$myuserid' and password='$mypassword' and position='$my_position'";
$sql1="select user_name from user where user_id='$myuserid'";
$result=mysqli_query($conn, $sql);
$result1= mysqli_query($conn, $sql1);
while($array1=mysqli_fetch_row($result))
{
$id_1= $array1[0];
}
setcookie("id", $id_1, time()+3600, "/", "", 0);
while($array=mysqli_fetch_row($result1))
{
$name_2= $array[0];
}
setcookie("name", $name_2 , time()+3600, "/","", 0);
$count= mysqli_num_rows($result);
$count1=mysqli_num_rows($result1);
if($count==1 and $count1==1)
{
if($my_position=='employee')
{
$_session['user_name'] = $id_1;
$_session['user_id'] = $myuserid;
header("location:employee.php");
}
else if($my_position=='admin')
{
$_session['user_id'] = $myuserid;
header("location:admin.php");
}
else if($my_position=='officer/scientist')
{
$_session['user_id'] = $myuserid;
header("location:officer_scientist.php");
}
}
else
{
$error="your login name or password is invalid";
echo $error;
}
mysqli_close($conn);
}
?>
<!doctype html>
<html>
<head>
<title>Leave Automation System</title>
<link rel="icon" href="http://localhost/registration/logo.png" >
<link rel="stylesheet" href="http://localhost/registration/style1.css">
</head>
<body >
<center>
<img src="http://localhost/registration/logo.png" height="250" width= "250">
</center>
<div class="header">
<h2>Login</h2>
</div>
<form action="" method="POST">
<div class="input-group">
<label>Position</label>
<select id="role" name="position">
<option value="select">SELECT</option>
<option value="admin">ADMIN</option>
<option value="officer/scientist">OFFICER\SCIENTIST</option>
<option value="employee" >EMPLOYEE</option>
</select>
</div>
<div class="input-group">
<label>UserID</label>
<input type="text" id="user_id" name="userid" placeholder="User ID">
</div>
<div class="input-group">
<label>Password</label>
<input type="password" id="password" name="password" placeholder="Password">
</div>
<div class="input-group">
<center>
<button type="submit" name="register" class="btn">Login</button>
<center>
</div>
</form>
<footer id="footer">
<p>Copyright © WESEE-ANNEXE | Developed by: Manish Mishra</p>
</footer>
</body>
</html>