-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd_department.php
52 lines (50 loc) · 1.69 KB
/
add_department.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
<?php
require('top.inc.php');
if($_SESSION['ROLE']!=1){
header('location:add_employee.php?id='.$_SESSION['USER_ID']);
die();
}
$department='';
$id='';
if(isset($_GET['id'])){
$id=mysqli_real_escape_string($con,$_GET['id']);
$res=mysqli_query($con,"select * from department where id='$id'");
$row=mysqli_fetch_assoc($res);
$department=$row['department'];
}
if(isset($_POST['department'])){
$department=mysqli_real_escape_string($con,$_POST['department']);
if($id>0){
$sql="update department set department='$department' where id='$id'";
}else{
$sql="insert into department(department) values('$department')";
}
mysqli_query($con,$sql);
header('location:index.php');
die();
}
?>
<div class="content pb-0">
<div class="animated fadeIn">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header"><strong>Department</strong><small> Form</small></div>
<div class="card-body card-block">
<form method="post">
<div class="form-group">
<label for="department" class=" form-control-label">Department Name</label>
<input type="text" value="<?php echo $department?>" name="department" placeholder="Enter your department name" class="form-control" required></div>
<button type="submit" class="btn btn-lg btn-info btn-block">
<span id="payment-button-amount">Submit</span>
</button>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
require('footer.inc.php');
?>