-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaddToMarket.php
More file actions
56 lines (50 loc) · 1.64 KB
/
addToMarket.php
File metadata and controls
56 lines (50 loc) · 1.64 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
<?php
session_start();
if(!isset($_SESSION["realty_status"])) {
$_SESSION["realty_status"] = "Visitor";
echo "<h1>You must be logged in to use this feature.</h1>";
return;
}
$userID =($_SESSION['id']);
$mysqli;
$x = 0;
foreach($_POST['myHousesBox'] as $propertyID) {
try {
$user = "root";
$password = "";
$port = getenv('OPENSHIFT_MYSQL_DB_PORT');
$user = getenv('OPENSHIFT_MYSQL_DB_USERNAME');
$password = getenv('OPENSHIFT_MYSQL_DB_PASSWORD');
$host = getenv('OPENSHIFT_MYSQL_DB_HOST');
$queryString = "SELECT count(*) FROM market WHERE prop_id = (?)";
$mysqli = new mysqli("$host", $user, $password, "housing", $port);
$stmt = $mysqli->prepare($queryString);
$stmt->bind_param("i", $propertyID);
$stmt->execute();
$stmt->bind_result($matches);
if($stmt->fetch()) {
if($matches != 0) {
echo "One or more of the houses you have selected is already on the market. You must refine your changes. $property_id";
return;
}
}
else {
echo "ERROR MARKETING HOME";
return;
}
echo "MARKER...";
// Put the house on the market
$stmt->close();
$userID = $_SESSION['id'];
$price = $_POST['salePrice'];
$queryString = "INSERT INTO market (user_id, prop_id, price) VALUES (?,?,?)";
$stmt = $mysqli->prepare($queryString);
$stmt->bind_param("iid",$userID, $propertyID, $price);
$stmt->execute();
}
catch (Exception $e){;}
++$x;
}
$mysqli->close();
header("Location: market.php");
?>