-
Notifications
You must be signed in to change notification settings - Fork 0
/
tourism_place.php
196 lines (183 loc) · 7.02 KB
/
tourism_place.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
<?php
include("header.php");
if (!isset($_SESSION['staffid'])) {
echo "<script>window.location='index.php';</script>";
}
if (isset($_POST['submit'])) {
$tourism_place = mysqli_real_escape_string($con, $_POST['tourism_place']);
$description = mysqli_real_escape_string($con, $_POST['description']);
$feature = mysqli_real_escape_string($con, $_POST['feature']);
if (isset($_GET['editid'])) {
$sql = "UPDATE tourism_place SET location_id='$_POST[location_id]',tourism_place='$tourism_place',description='$description',feature='$feature',status='$_POST[status]' WHERE tourism_placeid='$_GET[editid]'";
$qsql = mysqli_query($con, $sql);
echo mysqli_error($con);
if (mysqli_affected_rows($con) == 1) {
echo "<script>alert('Tourism place record updated successfully..');</script>";
}
} else {
$sql = "INSERT INTO tourism_place(location_id,tourism_place,description,feature,status) values('$_POST[location_id]','$tourism_place','$description','$feature','$_POST[status]')";
$qsql = mysqli_query($con, $sql);
echo mysqli_error($con);
if (mysqli_affected_rows($con) == 1) {
echo "<script>alert('Tourism place Record inserted..');</script>";
echo "<script>window.location='tourism_place.php';</script>";
}
}
}
if (isset($_GET['editid'])) {
$sqledit = "SELECT * FROM tourism_place WHERE tourism_placeid='$_GET[editid]'";
$qsqledit = mysqli_query($con, $sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
}
?>
<!-- Sub Banner Start -->
<div class="mg_sub_banner">
<div class="container">
<h2>Tourism place</h2>
</div>
</div>
<!-- Sub Banner Start -->
<!-- Main Contant Wrap Start -->
<div class="iqoniq_contant_wrapper">
<section>
<div class="container">
<form method="post" action="" onsubmit="return validatesubmit()">
<div class="row">
<!-- Hotel Destination Start -->
<div class="col-md-12 col-sm-12">
<div class="mg_hotel_destination fancy-overlay">
<div class="text">
<div class="row">
<div class="col-md-2 boldfont">
Location
</div>
<div class="col-md-10">
<select placeholder="Enter the location" name="location_id" id="location_id" class="form-control">
<option value="">Select Location</option>
<?php
$sqltourism_location = "SELECT * FROM tourism_location where status='Active'";
$qsqltourism_location = mysqli_query($con, $sqltourism_location);
while ($rstourism_location = mysqli_fetch_array($qsqltourism_location)) {
if ($rstourism_location['location_id'] == $rsedit['location_id']) {
echo "<option value='$rstourism_location[location_id]' selected>$rstourism_location[location_name]</option>";
} else {
echo "<option value='$rstourism_location[location_id]'>$rstourism_location[location_name]</option>";
}
}
?>
</select>
<span id="errlocation_id" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Tourism place
</div>
<div class="col-md-10">
<input type="text" name="tourism_place" id="tourism_place" class="form-control" placeholder="Enter Tourism place" value="<?php echo $rsedit['tourism_place']; ?>">
<span id="errtourism_place" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Description
</div>
<div class="col-md-10">
<textarea placeholder="Enter description" name="description" id="description" class="form-control"><?php echo $rsedit['description']; ?></textarea>
<script src="https://cdn.tiny.cloud/1/vkp7vwptosm1ao2ztjqdp0riscxgp2sxw81z6ma02p9h4oqc/tinymce/5/tinymce.min.js"></script>
<script>
tinymce.init({
selector: 'textarea'
});
</script>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Feature
</div>
<div class="col-md-10">
<textarea placeholder="Enter Feature and highlights" name="feature" id="feature" class="form-control"><?php echo $rsedit['feature']; ?></textarea>
<script src="https://cdn.tiny.cloud/1/vkp7vwptosm1ao2ztjqdp0riscxgp2sxw81z6ma02p9h4oqc/tinymce/5/tinymce.min.js"></script>
<script>
tinymce.init({
selector: 'textarea'
});
</script>
</div>
</div><br>
<div class="row">
<div class="col-md-2 boldfont">
Status
</div>
<div class="col-md-10">
<select name="status" id="status" class="form-control">
<option value="">Select status</option>
<?php
$arr = array("Active", "Inactive");
foreach ($arr as $val) {
if ($val == $rsedit['status']) {
echo "<option value='$val' selected>$val</option>";
} else {
echo "<option value='$val'>$val</option>";
}
}
?>
</select>
<span id="errstatus" class="errmsg flash"></span>
</div>
</div><br>
<div class="row">
<div class="col-md-2">
</div>
<div class="col-md-10">
<input type="submit" name="submit" id="submit" class="form-control btn btn-warning " style="width: 250px;height:50px;">
</div>
</div><br>
</form>
</div>
</div>
</div>
<!-- Hotel Destination End -->
</div>
</div>
</section>
</div>
<!-- Main Contant Wrap End -->
<?php
include("footer.php");
?>
<script>
function validatesubmit() {
var alphaExp = /^[a-zA-Z]+$/; //Variable to validate only alphabets
var alphaspaceExp = /^[a-zA-Z\s]+$/; //Variable to validate only alphabets with space
var alphanumericExp = /^[a-zA-Z0-9]+$/; //Variable to validate only alphanumerics
var numericExpression = /^[0-9]+$/; //Variable to validate only numbers
var emailpattern = /^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$/; //For email id
var i = 0;
$(".errmsg").empty();
if (document.getElementById("location_id").value == "") {
document.getElementById("errlocation_id").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i> Kindly select Location...";
i = 1;
}
//
//errlocation_id errtourism_place errstatus
if (!document.getElementById("tourism_place").value.match(alphaspaceExp)) {
document.getElementById("errtourism_place").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i> Kindly enter valid tourism Place.....";
i = 1;
}
if (document.getElementById("tourism_place").value == "") {
document.getElementById("errtourism_place").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Tourism place should not be empty...";
i = 1;
}
if (document.getElementById("status").value == "") {
document.getElementById("errstatus").innerHTML = " <i class='fa fa-times-circle' aria-hidden='true'></i>Kindly select status...";
i = 1;
}
if (i == 0) {
return true;
} else {
return false;
}
}
</script>