-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateStatus.php
182 lines (114 loc) · 3.47 KB
/
updateStatus.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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
<?php
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Scripting/EmptyPHP.php to edit this template
*/
//include 'includes/db_connect.php';
$databaseCon = mysqli_connect("localhost", "root", "root", "yourhome");
if(!$databaseCon)
die ("connection failed: ". mysqli_connect_errno());
if(isset($_POST["action"])){
if($_POST["action"] == "accept"){
Accept();
} else if($_POST["action"] == "declin"){
Declin();
}else{
echo 'eror action';
}
}
function Accept(){
global $databaseCon;
$rentalID = $_POST['id'];
$propID = $_POST['propID'];
$sql3 = "UPDATE rentalapplication
SET application_status_id=333333
WHERE id =$rentalID";
$result3 = mysqli_query($databaseCon, $sql3);
$sql4 = "UPDATE rentalapplication
SET application_status_id=222222
WHERE property_id = $propID AND id <> $rentalID";
$result4 = mysqli_query($databaseCon, $sql4);
$rows = mysqli_affected_rows($databaseCon);
if(!$result4){
echo 0;
exit;
}
echo 1;
}
function Declin(){
global $databaseCon;
$rentalID = $_POST['id'];
$propID = $_POST['propID'];
$sql2 = "UPDATE rentalapplication
SET application_status_id=222222
WHERE id =$rentalID";
$result2 = mysqli_query($databaseCon, $sql2);
$rows = mysqli_affected_rows($databaseCon);
if($rows==0){
echo 0;
exit;
}
echo 1;
}
/*$databaseCon = mysqli_connect("localhost", "root", "root", "yourhome");
if(!$databaseCon)
die ("connection failed: ". mysqli_connect_errno());
if(isset($_POST["action"])){
// Choose a function depends on value of $_POST["action"]
if($_POST["action"] == "accept"){
accept();
} else if($_POST["action"] == "decline"){
decline();
}
//header("Location: HomeOwner.php");
}
function decline(){
global $databaseCon;
$rentalID = $_GET['id'];
$propID = $_GET['propID'];
$btn = $_GET['action'];
if($btn == "decline"){
$sql2 = "UPDATE rentalapplication
SET application_status_id=222222
WHERE id =$rentalID";
$result2 = mysqli_query($databaseCon, $sql2);
if($result2){
echo "Status updated successfully";
}else{
echo "Error: Missing parameters";
}
}
if($rows==0){
echo 0;
exit;
}
echo 1;
}
function accept(){
global $databaseCon;
$rentalID = $_GET['id'];
$propID = $_GET['propID'];
$btn = $_GET['action'];
if($btn == "accept"){
$sql3 = "UPDATE rentalapplication
SET application_status_id=333333
WHERE id =$rentalID";
$result3 = mysqli_query($databaseCon, $sql3);
$sql4 = "UPDATE rentalapplication
SET application_status_id=222222
WHERE property_id = $propID AND id <> $rentalID";
$result4 = mysqli_query($databaseCon, $sql4);
if($result4){
echo "Status updated successfully";
}else{
echo "Error: Missing parameters";
}
}
if($rows==0){
echo 0;
exit;
}
echo 1;
}
mysqli_close($databaseCon); */
?>