-
Notifications
You must be signed in to change notification settings - Fork 0
/
Update.php
122 lines (117 loc) · 3.53 KB
/
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
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
<?php //require_once ("Connection.php"); ?>
<?php
//global $Connection;
$Connection = mysqli_connect("localhost", "root", "", "record");
$Update_Recored = @$_GET["Update"];
$ShowQuery = "SELECT * FROM emp_record WHERE id = '$Update_Recored' ";
$Update = mysqli_query($Connection, $ShowQuery);
while ($DataRows = mysqli_fetch_array($Update)) {
$Update_Id = $DataRows['id'];
$EName = $DataRows['enam'];
$SSN = $DataRows['ssn'];
$Dept = $DataRows['dept'];
$Salary = $DataRows['salary'];
$HomeAddress = $DataRows['homeaddress'];
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Update</title>
<link rel="stylesheet" href="">
</head>
<style type="text/css">
input[type="text"], texterea {
border: 1px solid dashed;
background-color: rgb(221, 216, 212);
width: 480px;
padding: .5em;
font-size: 1.0em;
}
input[type="submit"] {
color: white;
font-size: 1.0em;
font-family: Bitter, Georgia, Times, "Times New Roman", serif;
width: 200px;
height: 40px;
background-color: #5D0580;
border: 5px solid;
border-bottom-left-radius: 35px;
border-bottom-right-radius: 35px;
border-top-left-radius: 35px;
border-top-right-radius: 35px;
}
.FieldInfo {
color: rgb(251, 27, 214);
font-family: Bitter, Georgia, "Times New Roman", Times, serif;
font-size: 1em;
}
.success {
color: rgb(158, 27, 214);
font-family: Bitter,Georgia,"Times New Roman",Times,serif;
font-size: 1.4em;
font-weight:bold;
}
.FieldInfoHeading {
color: rgb(251, 174, 44);
font-family: Bitter,Georgia,"Times New Roman",Times,serif;
font-size: 1.3em;
}
#center {
width: 500px;
margin:0 auto;
}
fieldset {
background-image: url("ems1.jpg");
background-repeat: repeat-x;
}
body {
background-image: url("2.jpg");
background-repeat: repeat;
}
</style>
<body>
<div id="center">
<form action="Update.php?Update_Id=<?php echo $Update_Id; ?>" method="GET" enctype="multipart/form-data">
<fieldset>
<span class="FieldInfo">Employee Name:</span> <br>
<input type="text" name="EName" value="<?php echo $EName; ?>"> <br>
<span class="FieldInfo">Social Security Number:</span> <br>
<input type="text" name="SSN" value="<?php echo $SSN; ?>"> <br>
<span class="FieldInfo">Department:</span> <br>
<input type="text" name="Dept" value="<?php echo $Dept; ?>"> <br>
<span class="FieldInfo">Salary:</span> <br>
<input type="text" name="Salary" value="<?php echo $Salary; ?>"> <br>
<span class="FieldInfo">Home Address:</span> <br>
<textarea name="HomeAddress">
<?php echo $HomeAddress; ?>
</textarea> <br>
<input type="submit" name="Submit" value="Submit Your Record">
</fieldset>
</form>
</div>
</body>
</html>
<?php
//This PHP BLOck is for Editing the data that you got in your form
$Connection = mysqli_connect("localhost", "root", "", "record");
if (isset($_POST['Submit'])) {
$Update_Id = $_GET['Update_Id'];
$EName = $_POST['EName'];
$SSN = $_POST['SSN'];
$Dept = $_POST['Dept'];
$Salary = $_POST['Salary'];
$HomeAddress = $_POST['HomeAddress'];
$UpdateQuery = "UPDATE emp_record SET enam = '$EName', ssn = '$SSN', dept = '$Dept', salary = '$Salary', homeaddress = '$HomeAddress' WHERE id = '$Update_Id' ";
$Execute = mysqli_query($Connection, $UpdateQuery);
if ($Execute) {
function redirect_to($NewLocation) {
header("Location: ".$NewLocation);
exit();
}
redirect_to("Update_Into_Database.php?Updated=Record has been Updated Successfully");
}
}
?>