-
Notifications
You must be signed in to change notification settings - Fork 0
/
emp_update.php
95 lines (68 loc) · 2.67 KB
/
emp_update.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
<?php
include 'connect.php';
$id =NULL;
$id = $_GET['updateid'];
$sql = "Select * from `employee` where `id`='$id' ";
$result = mysqli_query($con,$sql);
$row = mysqli_fetch_assoc($result);
$empno1=$row['empno'];
$empname1= $row['name'];
$dob1= $row['dob'];
$address1= $row['address'];
if(isset($_POST['submit'])){
$id = $_POST['empid'];
$empno= $_POST['empno'];
$empname= $_POST['empname'];
$dob= $_POST['dob'];
$address= $_POST['address'];
$sql = "UPDATE `employee` SET `empno`= '$empno',`name`= '$empname',`dob`= '$dob',`address`= '$address' WHERE `id` = '$id'";
$result = mysqli_query($con,$sql);
if($result){
header('location:emp_view.php');
}
else{
die(mysqli_error($con));
}
}
$id = $_GET['updateid'];
?>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Employee Update</title>
</head>
<body>
<?php include_once 'nav.php';?>
<div class ="container">
<h1> Update Employee</h1><br>
<form method = "post" action="emp_update.php">
<div class="form-group">
<label >Employee Number</label>
<input type="text" value="<?php echo $id; ?>" class ="form-control" name="empid" style="Display:none">
<input type="text" value="<?php echo $empno1; ?>" class ="form-control" name="empno" >
</div>
<div class="form-group">
<label >Employee Name</label>
<input type="text" value="<?php echo $empname1; ?>" class ="form-control" name="empname" >
</div>
<div class="form-group">
<label >Date of Birth</label>
<input type="date" value="<?php echo $dob1; ?>" class ="form-control" name="dob" >
</div>
<div class="form-group">
<label >Address</label>
<input type="text" value="<?php echo $address1; ?>" class ="form-control" name="address" >
</div>
<button type="submit" class="btn btn-primary" name ="submit" >Update</button>
<button class ="btn btn-primary my-5">
<a href = "emp_view.php" class="text-light ">Display All Employees</a>
</button>
</form>
</div>
</body>
</html>