-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_building.php
88 lines (67 loc) · 2.82 KB
/
edit_building.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
<?php
$page_title = "Edit | Building";
$cookie_name = 'users';
$email = $_COOKIE[$cookie_name];
require('include/files/header.php');
require("include/files/dbconnect.php");
$idGlobal = $_GET['id'];
if (!empty($_GET['id'])) {
$query = "SELECT * FROM buildings WHERE ID='" . $_GET['id'] . "'";
$result = mysqli_query( $conn, $query );
$row = mysqli_fetch_assoc($result);
if (isset( $_POST[ 'buildingID' ], $_POST[ 'Name' ], $_POST[ 'Address' ], $_POST[ 'city' ], $_POST[ 'state' ], $_POST['zip'])) {
$id = $_REQUEST['buildingID'];
$name = $_REQUEST[ 'Name' ];
$address = $_REQUEST[ 'Address' ];
$city = $_REQUEST[ 'city' ];
$state = $_REQUEST['state'];
$zip = $_REQUEST[ 'zip' ];
echo $id;
echo $name;
echo $address;
echo $city;
echo $state;
echo $zip;
$sql = "UPDATE buildings SET NAME='$name', ADDRESS='$address', CITY='$city'. STATE='$state', ZIPCODE='$zip' WHERE ID='$id'";
//$sql = "UPDATE users SET FIRST_NAME='" . $first_name . "', LAST_NAME='" . $last_name . "', EMAIL='" . $email . "', PERMISSION_LEVEL='" . $permLvl . "', SCHOOL='" .$side . "' WHERE ID='" . $id . "'";
if (mysqli_query( $conn, $sql ) ) {
header( "Location: buildings.php" );
} else {
//header( "Location: edit_building.php?id=$id" );
}
mysqli_close($conn);
}
}
?>
<div class="container">
<form action="edit_building.php?id=<?php echo $_GET['id']?>" method="POST" style="width:50%; display:inline-block; padding-top:5%">
<div class="form-group">
<label for="buildingID">ID</label>
<input type="number" class="form-control" name="buildingID" id="buildingID" value=<?php echo $row['ID'] ; ?> readonly>
</div>
<div class="form-group">
<label for="Name">Building Name</label>
<input type="text" class="form-control" name="Name" id="Name" value=<?php echo $row['NAME'];?> required>
</div>
<div class="form-group">
<label for="Address">Building Address</label>
<input type="text" class="form-control" name="Address" id="Address" value=<?php echo $row['ADDRESS'];?> required>
</div>
<div class="form-group">
<label for="city">City</label>
<input type="text" class="form-control" name="city" id="city" value=<?php echo $row['CITY'];?> required>
</div>
<div class="form-group">
<label for="state">State</label>
<input type="text" class="form-control" name="state" id="state" value=<?php echo $row['STATE'];?> required>
</div>
<div class="form-group">
<label for="zip">Zipcode</label>
<input type="text" class="form-control" name="zip" id="zip" value=<?php echo $row['ZIPCODE'];?> required>
</div>
<button type="submit" class="btn2" name="update" id="update" style="display:inline-block;">Update Building</button>
</form>
</div>
<?php
require('include/files/footer.php');
?>