-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditproperty.php
More file actions
181 lines (154 loc) · 7.12 KB
/
editproperty.php
File metadata and controls
181 lines (154 loc) · 7.12 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
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
<!DOCTYPE HTML>
<html>
<head>
<title> Using staff details </title>
<link rel="stylesheet" href="style.css" />
</head>
<body bgcolor="white">
<h1> Edit Propertys </h1>
<?php
$formtop='<form <action="<?php echo htmlentities($_SERVER[$redir]); ?>" method="post">';
$menu=$formtop.'<select name="second" style="display: none"> <option value=""></option></select> <input type="text" name ="third" value="" style="display: none"';
$subbutton='<input type="submit" name="formSubmit" value="Submit" /></form> <a href="index.html"> Back to index </a>';
$formdetail="";
$query="";
$wherecond="";
$result_id="";
$Innputform="";
if(isset($_POST['formSubmit'])) {$query= $_POST['first'];
$wherecond= $_POST['second'];
$Innputform=$_POST['third'];
if ($query && $Innputform){
$Street=$_POST["Street"];
$Address=$_POST["Area"];
$Rent=$_POST["Rent"];
$PNO=$_POST["Pno"];
$BNO=$_POST["Bno"];
$Type=$_POST["Rooms"];
}
}
$conn_id = @mysql_connect ("server", "id","password")
or exit ();
mysql_select_db ("Dreamhome_km32", $conn_id);
if (!$query && !$wherecond){
$formdetail.=$menu.'
<label for="first">Please choose how you like to search :</label><br>
<select name="first">
<option value="">Select an option...</option>
<option value="Update">Update</option>
<option value="Insert">Insert</option>
<option value="Delete">Delete</option>
</select>
<br>'.$subbutton;
}
if ($query==="Update" && !$wherecond){
$result_id = mysql_query ("select Street, Area, Pno from property_for_rent") or exit ();
if ($result_id){
PrintF("<p>Please select Property : </p>");
$menu=$formtop.'<select name="first" style="display: none">
<option value='.$query.'></option>
</select> <input type="text" name ="third" value="" style="display: none"';
$menu.="<label for='second'> Search parameters : </label> <select name='second'><option value=''>Select...</option>";
while ($row = mysql_fetch_array ($result_id)){
$menu.="<option value=".$row["Pno"].">".$row["Street"]." ".$row["Area"]." ".$row["Pno"]."</option>";
}
$menu.=$subbutton;
mysql_free_result ($result_id);
}
}
if ($query==="Update" && $wherecond){
$result_id = mysql_query ("select * from property_for_rent where Pno='".$wherecond."'") or exit ();
$formdetail=$formtop.'<select name="second" style="display: none"> <option value='.$wherecond.'></option></select>
<input type="text" name ="third" value="True" style="display: none">
<select name="first" style="display: none">
<option value='.$query.'></option>
</select>';
if ($result_id){
$row = mysql_fetch_array ($result_id);
printf("Street : ".$row["Street"]);
printf($formdetail.
"<br> Street : <input type='text' name ='Street' value=".$row["Street"]." readonly>".
"<br> Area : <input type='text' name ='Area' value='".$row["Area"]."' readonly>".
"<br> Property No. : <input type='text' name ='Pno' value='".$row["Pno"]."' readonly>".
"<br> Rent : <input type='text' name ='Rent' value='".$row["Rent"]."'>".
'<br> <select name="Rooms">
<option value="">Select an option...</option>
<option value="House">House</option>
<option value="Flat">Flat</option>
<option value="Bungalow">Bungalow</option>
</select> '.
"<br> Branch : <input type='text' name ='Bno' value=".$row["Bno"].">".$subbutton);
}
}
if ($query==="Insert" && !$Innputform){
$formdetail=$formtop.'<select name="second" style="display: none"> <option value=""></option></select>
<input type="text" name ="third" value="True" style="display: none">'
.'<select name="first" style="display: none">
<option value='.$query.'></option>
</select>';
$formdetail.=
"<br> Street : <input type='text' name ='Street'>".
"<br> Area : <input type='text' name ='Area'>".
"<br> Property No. : <input type='text' name ='Pno'>".
"<br> Rent : <input type='text' name ='Rent'>".
'<br> <label for ="Rooms" > Type : </label> <select name="Rooms">
<option value="">Select an option...</option>
<option value="House">House</option>
<option value="Flat">Flat</option>
<option value="Bungalow">Bungalow</option>
</select> ';
$result_id = mysql_query ("select distinct (bno) from branch") or exit ();
if ($result_id){
$formdetail.='<label for="Bno"> Select a Branch Number </label><select name="Bno">';
while ($row = mysql_fetch_array ($result_id)){
$formdetail.="<option value=".$row['bno'].">".$row['bno']."</option>";
}}
$formdetail.="</select>".$subbutton;
}
if ($query==="Delete" && !$wherecond){
$result_id = mysql_query ("select Street, Area, Pno from property_for_rent") or exit ();
if ($result_id){
PrintF("<p>Please select Property : </p>");
$menu=$formtop.'<select name="first" style="display: none">
<option value='.$query.'></option>
</select> <input type="text" name ="third" value="" style="display: none"';
$menu.="<label for='second'> Search parameters : </label> <select name='second'><option value=''>Select...</option>";
while ($row = mysql_fetch_array ($result_id)){
$menu.="<option value=".$row["Pno"].">".$row["Street"]." ".$row["Area"]." ".$row["Pno"]."</option>";
}
$menu.=$subbutton;
mysql_free_result ($result_id);
}
}
if ($query==="Delete" && $wherecond){
$formdetail=$formtop.'<select name="second" style="display: none"> <option value=""></option></select>
<input type="text" name ="third" value="" style="display: none" ><select name="first" style="display: none">
<option value=""></option> </select>';
$result_id = mysql_query ("select Street, Area, Pno from property_for_rent where Pno='".$wherecond."'") or exit ();
if ($result_id){
$row = mysql_fetch_array ($result_id);
$query="Deleting : ".$row["Street"]." ".$row["Area"]." ".$row["Pno"];}
if ( mysql_query ("delete from property_for_rent where Pno='".$wherecond."'") ) {printf($query);}
}
if ($Innputform){
$formdetail=$formtop.'<select name="second" style="display: none"> <option value=""></option></select>
<input type="text" name ="third" value="True" style="display: none" ><select name="first" style="display: none">
<option value=""></option> </select>';
if ($query==="Update"){
if( mysql_query ("Update property_for_rent SET Street='".$Street."', Area='".$Address."', Rent='".$Rent."', Bno='".$BNO."', Type='".$Type."' where pno='".$wherecond."'"))
{printf("Updated");}
else { printf("Failed update");}}
if ($query==="Insert")
{
if( mysql_query ("Insert into property_for_rent (Street, Area, Rent, Pno, Bno, Type) Values ('".$Street."','".$Address."','".$Rent."','".$PNO."','".
$BNO."','".$Type."')")){ printf("Property Inserted");} else { printf("Failed update ");}
}
$formdetail=$formtop.'<select name="second" style="display: none"> <option value=""></option></select>
<input type="text" name ="third" value="True" style="display: none" <select name="first" style="display: none">
<option value=""></option> </select>';
}
?>
<span><?php printf( $formdetail); ?> </span>
<span><?php printf( $menu); ?> </span>
</body>
</html>