-
Notifications
You must be signed in to change notification settings - Fork 0
/
editProperty.php
35 lines (31 loc) · 1.44 KB
/
editProperty.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
<?php
// Get the unit data
$address = filter_input(INPUT_POST, 'address');
$dateAvailable = filter_input(INPUT_POST, 'dateAvailable');
$advertised = filter_input(INPUT_POST, 'advertised', FILTER_VALIDATE_INT);
$rentAmount = filter_input(INPUT_POST, 'rentAmount', FILTER_VALIDATE_INT);
$squareFeet = filter_input(INPUT_POST, 'squareFeet', FILTER_VALIDATE_INT);
$bedrooms = filter_input(INPUT_POST, 'bedrooms', FILTER_VALIDATE_INT);
$bathrooms = filter_input(INPUT_POST, 'bathrooms', FILTER_VALIDATE_FLOAT);
$unitID = filter_input(INPUT_POST, 'unitID');
// Validate inputs
//connect to the database
require_once('database.php');
// Add the property to the database
$query = 'UPDATE units
SET address = :address, dateAvailable = :dateAvailable, advertised = :advertised, rentAmount = :rentAmount, squareFeet = :squareFeet, bedrooms = :bedrooms, bathrooms = :bathrooms
WHERE unitID = :unitID';
$statement = $db->prepare($query);
$statement->bindValue(':address', $address);
$statement->bindValue(':dateAvailable', $dateAvailable);
$statement->bindValue(':advertised', $advertised);
$statement->bindValue(':rentAmount', $rentAmount);
$statement->bindValue(':squareFeet', $squareFeet);
$statement->bindValue(':bedrooms', $bedrooms);
$statement->bindValue(':bathrooms', $bathrooms);
$statement->bindValue(':unitID', $unitID);
$statement->execute();
$statement->closeCursor();
// Display the Product List page
include('propertyList.php');
?>