-
Notifications
You must be signed in to change notification settings - Fork 12
/
edit.php
184 lines (140 loc) · 6.95 KB
/
edit.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
<?php
require_once ('process/dbh.php');
$sql = "SELECT * FROM `employee` WHERE 1";
//echo "$sql";
$result = mysqli_query($conn, $sql);
if(isset($_POST['update']))
{
$id = mysqli_real_escape_string($conn, $_POST['id']);
$firstname = mysqli_real_escape_string($conn, $_POST['firstName']);
$lastname = mysqli_real_escape_string($conn, $_POST['lastName']);
$email = mysqli_real_escape_string($conn, $_POST['email']);
$birthday = mysqli_real_escape_string($conn, $_POST['birthday']);
$contact = mysqli_real_escape_string($conn, $_POST['contact']);
$address = mysqli_real_escape_string($conn, $_POST['address']);
$gender = mysqli_real_escape_string($conn, $_POST['gender']);
$nid = mysqli_real_escape_string($conn, $_POST['nid']);
$dept = mysqli_real_escape_string($conn, $_POST['dept']);
$degree = mysqli_real_escape_string($conn, $_POST['degree']);
//$salary = mysqli_real_escape_string($conn, $_POST['salary']);
// $result = mysqli_query($conn, "UPDATE `employee` SET `firstName`='$firstname',`lastName`='$lastname',`email`='$email',`password`='$email',`gender`='$gender',`contact`='$contact',`nid`='$nid',`salary`='$salary',`address`='$address',`dept`='$dept',`degree`='$degree' WHERE id=$id");
$result = mysqli_query($conn, "UPDATE `employee` SET `firstName`='$firstname',`lastName`='$lastname',`email`='$email',`birthday`='$birthday',`gender`='$gender',`contact`='$contact',`nid`='$nid',`address`='$address',`dept`='$dept',`degree`='$degree' WHERE id=$id");
echo ("<SCRIPT LANGUAGE='JavaScript'>
window.alert('Succesfully Updated')
window.location.href='viewemp.php';
</SCRIPT>");
}
?>
<?php
$id = (isset($_GET['id']) ? $_GET['id'] : '');
$sql = "SELECT * from `employee` WHERE id=$id";
$result = mysqli_query($conn, $sql);
if($result){
while($res = mysqli_fetch_assoc($result)){
$firstname = $res['firstName'];
$lastname = $res['lastName'];
$email = $res['email'];
$contact = $res['contact'];
$address = $res['address'];
$gender = $res['gender'];
$birthday = $res['birthday'];
$nid = $res['nid'];
$dept = $res['dept'];
$degree = $res['degree'];
}
}
?>
<html>
<head>
<title>View Employee | Admin Panel | XYZ Corporation</title>
<!-- Icons font CSS-->
<link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">
<link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
<!-- Font special for pages-->
<link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i" rel="stylesheet">
<!-- Vendor CSS-->
<link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
<link href="vendor/datepicker/daterangepicker.css" rel="stylesheet" media="all">
<!-- Main CSS-->
<link href="css/main.css" rel="stylesheet" media="all">
</head>
<body>
<header>
<nav>
<h1>XYZ Corp.</h1>
<ul id="navli">
<li><a class="homeblack" href="index.html">HOME</a></li>
<li><a class="homeblack" href="addemp.php">Add Employee</a></li>
<li><a class="homered" href="viewemp.php">View Employee</a></li>
<li><a class="homeblack" href="elogin.html">Log Out</a></li>
</ul>
</nav>
</header>
<div class="divider"></div>
<!-- <form id = "registration" action="edit.php" method="POST"> -->
<div class="page-wrapper bg-blue p-t-100 p-b-100 font-robo">
<div class="wrapper wrapper--w680">
<div class="card card-1">
<div class="card-heading"></div>
<div class="card-body">
<h2 class="title">Update Employee Info</h2>
<form id = "registration" action="edit.php" method="POST">
<div class="row row-space">
<div class="col-2">
<div class="input-group">
<input class="input--style-1" type="text" name="firstName" value="<?php echo $firstname;?>" >
</div>
</div>
<div class="col-2">
<div class="input-group">
<input class="input--style-1" type="text" name="lastName" value="<?php echo $lastname;?>">
</div>
</div>
</div>
<div class="input-group">
<input class="input--style-1" type="email" name="email" value="<?php echo $email;?>">
</div>
<div class="row row-space">
<div class="col-2">
<div class="input-group">
<input class="input--style-1" type="text" name="birthday" value="<?php echo $birthday;?>">
</div>
</div>
<div class="col-2">
<div class="input-group">
<input class="input--style-1" type="text" name="gender" value="<?php echo $gender;?>">
</div>
</div>
</div>
<div class="input-group">
<input class="input--style-1" type="number" name="contact" value="<?php echo $contact;?>">
</div>
<div class="input-group">
<input class="input--style-1" type="number" name="nid" value="<?php echo $nid;?>">
</div>
<div class="input-group">
<input class="input--style-1" type="text" name="address" value="<?php echo $address;?>">
</div>
<div class="input-group">
<input class="input--style-1" type="text" name="dept" value="<?php echo $dept;?>">
</div>
<div class="input-group">
<input class="input--style-1" type="text" name="degree" value="<?php echo $degree;?>">
</div>
<input type="hidden" name="id" id="textField" value="<?php echo $id;?>" required="required"><br><br>
<div class="p-t-20">
<button class="btn btn--radius btn--green" type="submit" name="update">Submit</button>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- Jquery JS-->
<!-- <script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/select2/select2.min.js"></script>
<script src="vendor/datepicker/moment.min.js"></script>
<script src="vendor/datepicker/daterangepicker.js"></script>
<script src="js/global.js"></script> -->
</body>
</html>