-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateStaffForm.php
More file actions
71 lines (66 loc) · 1.61 KB
/
UpdateStaffForm.php
File metadata and controls
71 lines (66 loc) · 1.61 KB
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
<html>
<head>
<meta http-equiv="refresh" content="0; url=Staff.php" />
</head>
<body>
<?php
include "db.php";
// get content from form
if (!empty($_POST['id'])){
$id = $_POST["id"];
}
if (!empty($_POST['firstname'])){
$firstname = $_POST["firstname"];
}
if (!empty($_POST['surname'])){
$surname = $_POST["surname"];
}
if (!empty($_POST['position'])){
$position = $_POST["position"];
}
if (!empty($_POST['salary'])){
$salary = $_POST["salary"];
}
if (!empty($_POST['address'])){
$address = $_POST["address"];
}
if (!empty($_POST['city'])){
$city = $_POST["city"];
}
if (!empty($_POST['postcode'])){
$postcode = $_POST["postcode"];
}
if (!empty($_POST['email'])){
$email = $_POST["email"];
}
if (!empty($_POST['phonenumber'])){
$phonenumber = $_POST["phonenumber"];
}
if (!empty($_POST['branch'])){
$branch = $_POST["branch"];
}
if (!empty($_POST['password'])){
$password = $_POST["password"];
}
if (!empty($_POST['privileges'])){
$privileges = $_POST["privileges"];
}
// SQL Insert using variable names
$sql = "SELECT staffID FROM staff WHERE staffID='$id'";
$result = mysql_query($sql);
if(mysql_num_rows($result) <1){
echo "There is no staff member with such ID";
}
else{
if($salary==null)
{
$salary = 0;
}
mysql_query("Update staff SET sFname = '$firstname', sSurname = '$surname', position = '$position', salary = '$salary', sAddress = '$address', sCity = '$city', sPostcode = '$postcode',
sEmail = '$email', sPhoneNumber = '$phonenumber', branchID = '$branch', password = '$password', privileges = '$privileges'
WHERE staffID = '$id'", $db);
echo "Staff member was successfully updated <br>";
}
?>
</body>
</html>