-
Notifications
You must be signed in to change notification settings - Fork 0
/
data_insert.php
212 lines (181 loc) · 9.67 KB
/
data_insert.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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php include('inc/head.php'); ?>
<script type="text/javascript">
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('#uploaded')
.attr('src', e.target.result)
.width(auto)
.height(200);
};
reader.readAsDataURL(input.files[0]);
}
}
</script>
<body>
<?php include('inc/header.php'); ?>
<div id="wrapper" class="clearfix expand">
<?php include('inc/menu.php'); ?>
<div id="content" class="right">
<div class="breadcrumbs clearfix">
<ul class="breadcrumbs left">
<li><a href="#">DISTRIBUTED DATABASE SYSTEM</a></li>
<li><i class="fa fa-angle-right"></i></li>
<li>MINI PROJECT</li>
</ul>
</div>
<?php
if(isset($_POST["submit"])){
$name = $_POST["name"];
$plot_no = $_POST["plot_no"];
$location = $_POST["location"];
$landmark = $_POST["landmark"];
$street = $_POST["street"];
$city = $_POST["city"];
$state = $_POST["state"];
$pincode = $_POST["pincode"];
$area = $_POST["area"];
$price = $_POST["price"];
$description = $_POST["description"];
$target_dir = "photos/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Allow certain file formats
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg") {
echo "<div class='alerts'>
<div class='error'><p><strong>ERROR!</strong> ONLY JPG, JPEG or PNG FILES ARE ACCEPTED </p></div>
</div>";
$uploadOk = 0;
}
// Check if $uploadOk is set to 0 by an error
if ($uploadOk == 0) {
echo "<div class='alerts'>
<div class='error'><p><strong>ERROR!</strong> THERE WAS A PROBLEM </p></div>
</div>"; // if everything is ok, try to upload file
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
$filename = basename( $_FILES["fileToUpload"]["name"]);
$user = "rems1";
include "oci.php";
$query = "SELECT MAX(PROP_ID) as maximum FROM property";
$stid = oci_parse($conn, $query);
oci_execute($stid);
$row = oci_fetch_assoc($stid);
$prop_id = $row["MAXIMUM"] + 1;
$query = "INSERT INTO property (PROP_ID, NAME, PLOT_NO, LOCATION, LAND_MARK, STREET, CITY, STATE, PINCODE, AREA, PRICE, PHOTO, ADDN_INFO) VALUES ($prop_id, '$name', '$plot_no', '$location', '$landmark', '$street', '$city', '$state', '$pincode', '$area', $price, '$filename', '$description')";
$stid = oci_parse($conn, $query);
oci_execute($stid);
echo "<div class='alerts'>
<div class='success'><p><strong>SUCCESS!</strong>PROPERTY INSERTED SUCCESFULLY</p></div>
</div>";
} else {
echo "<div class='alerts'>
<div class='error'><p><strong>ERROR!</strong> THERE WAS A PROBLEM </p></div>
</div>";
}
}
}
?>
<form id="file-upload" class="upload" method="post" action="data_insert.php" enctype="multipart/form-data">
<h3>INSERT FORM</h3>
<div class="inner clearfix">
<fieldset class="error">
<label for="field1">NAME</label>
<div class="field">
<input type="text" placeholder="Name of the property" name="name">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field1">PLOT NO.</label>
<div class="field">
<input type="text" placeholder="Plot Number" name="plot_no">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field2">Location</label>
<div class="field">
<input type="text" placeholder="Location" name="location">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field1">LANDMARK</label>
<div class="field">
<input type="text" placeholder="Landmark" name="landmark">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field1">STREET</label>
<div class="field">
<input type="text" placeholder="Street" name="street">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field1">CITY</label>
<div class="field">
<select class="chosen-select" data-placeholder="City" name="city">
<option value="0"></option>
<option value="thane">THANE</option>
<option value="dombivli">DOMBIVLI</option>
</select>
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field1">STATE</label>
<div class="field">
<input type="text" placeholder="State" name="state">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field1">PINCODE</label>
<div class="field">
<input type="text" placeholder="Pincode" name="pincode">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field1">AREA</label>
<div class="field">
<input type="text" placeholder="Area" name="area">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset class="error">
<label for="field1">PRICE</label>
<div class="field">
<input type="text" placeholder="Price" name="price">
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<fieldset>
<label for="field7">IMAGE</label>
<div class="field clearfix">
<div id="profile-preview">
<img id="uploaded" src="images/avatar.png" /><br>
</div>
<input type="file" placeholder="Select file to upload" name="fileToUpload" name="fileToUpload" onchange="readURL(this);">
</div>
</fieldset>
<fieldset>
<label for="field13">DESCRIPTION</label>
<div class="field">
<textarea placeholder="Additional details of the property" name="description"></textarea>
<span class="error-alert">Please enter valid value</span>
</div>
</fieldset>
<input type="submit" value="SUBMIT" name="submit" class="right">
</div>
</form>
</div>
</div>
<?php include('inc/footer.php'); ?>
</body>
</html>