-
Notifications
You must be signed in to change notification settings - Fork 1
/
insert_manager.php
110 lines (110 loc) · 4.76 KB
/
insert_manager.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
109
110
<!DOCTYPE html>
<html>
<head>
<?php
session_start();
include "db_connection.php";
include 'gvar.php';
$Err = "";
?>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="MANAGER.css">
<link rel="stylesheet" type="text/css" href="empfunc.css">
<title>MANAGER</title>
</head>
<body>
<?php
if(isset($_SERVER['REQUEST_METHOD']))
{
if(isset($_POST['insert']))
{
$uname=trim($_POST['new_user']);
$pass=trim($_POST['new_pass']);
$pass=hash('sha256',$pass); // encrypting the password
$role=trim($_POST['role']);
if($role=='Manager')
{
$role=$manager;
} #this if for insertion of employee
else
{
$role=$employee;
}
$conn=OpenCon();
$flag=Insertemployees($conn,$uname,$pass,$role);
$id = mysqli_insert_id($conn);
?>
<div>
<?php
if($flag)
{
$Err = "Message: Employee $uname has been assigned ID $id!";
}
else
{
$Err = "Error occurred or Record doesn't exist";
echo mysqli_error($conn);
}
CloseCon($conn);
?>
</div>
<?php
}
}
?>
<?php
if(isset($_SESSION['role'])&&$_SESSION['role']==$manager)
{
?>
<header>
<nav>
<div class="logo">RENT-A-CAR</div>
<label for="btn" class="icon">
<span class="fa fa-bars"></span>
</label>
<input class="rad" type="checkbox" id="btn">
<ul>
<li><a href="./manager.php">HOME</a></li>
<li>
<label for="btn-1" class="show">EMPLOYEE +</label>
<a href="#">EMPLOYEE</a>
<input class="rad" type="checkbox" id="btn-1">
<ul>
<li><a href="./insert_manager.php">INSERT EMPLOYEE</a></li>
<li><a href="./delete_manager.php">DELETE EMPLOYEE</a></li>
<li><a href="./promote_manager.php">PROMOTE EMPLOYEE</a></li>
<li><a href="./update_manager.php">UPDATE PASSWORD</a></li>
</ul>
</li>
<li>
<label for="btn-2" class="show">CAR +</label>
<a href="#">CAR</a>
<input class="rad" type="checkbox" id="btn-2">
<ul>
<li><a href="./insert_car_manager.php">INSERT CAR</a></li>
<li><a href="./update_car_manager.php">UPDATE CAR</a></li>
<li><a href="./delete_car_manager.php">DELETE CAR</a></li>
</ul>
</li>   
</ul>
</nav>
</header>
<div class='e_ins'>
<form class='box' method='post' action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']);?>">
<h1>Insert Employee</h1>
<input type='text' placeholder='ENTER USERNAME' name='new_user' required></input>
<input type='password' placeholder='ENTER PASSWORD' name='new_pass' required></input>
<span>Select Your Role:</span><br>
<input type='radio' id="rad" value='Employee' name='role' checked ><span> Employee</span></input><br>
<input type='radio' id="rad" value='Manager' name='role' ><span> Manager</span></input>
<input type='submit' name='insert' value='Insert'></input>
<span>Message: <?php echo $Err; ?></span>
</form>
</div>
<?php
}
else
echo "You got unauthorized access!<br>";
?>
</body>
</html>