Repository navigation
Expand file tree
/
Copy pathwebads.php
More file actions
333 lines (308 loc) · 10.2 KB
/
Copy pathwebads.php
File metadata and controls
333 lines (308 loc) · 10.2 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
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
<?php
include("header.php");
if(isset($_POST['submit']))
{
//Upload image starts
$filename= rand(). $_FILES['advtimg']['name'];
move_uploaded_file($_FILES['advtimg']['tmp_name'],"imgwebads/".$filename);
//Upload image ends
if(isset($_GET['editid']))
{
//Update statement starts here
$sql = "UPDATE webads SET advttitle='$_POST[advttitle]'";
if($_FILES['advtimg']['name'] != "")
{
$sql = $sql .",advtimg='$filename'";
}
$sql = $sql . ",advtdescription='" . mysqli_real_escape_string($con,$_POST['advtdescription']) . "',advtemail='$_POST[advtemail]',advtwww='$_POST[advtwww]',advtaddress='$_POST[advtaddress]',advttype='$_POST[advttype]',status='$_POST[status]',contactno='$_POST[contactno]',cpc='$_POST[cpc]' WHERE webadid ='$_GET[editid]'";
$qsql = mysqli_query($con,$sql);
echo mysqli_error($con);
if(mysqli_affected_rows($con) ==1)
{
echo "<script>alert('Web Advertisement template record updated successfully..');</script>";
echo "<script>window.location='viewwebads.php';</script>";
}
//Update statement ends here
}
else
{
$sql = "INSERT INTO webads(advertiserid,advttitle,advtimg,advtdescription,advtemail,advtwww,advtaddress,advttype,status,contactno,cpc) VALUES('$_SESSION[advertiserid]','$_POST[advttitle]','$filename','" . mysqli_real_escape_string($con,$_POST['advtdescription']) . "','$_POST[advtemail]','$_POST[advtwww]','$_POST[advtaddress]','$_POST[advttype]','$_POST[status]','$_POST[contactno]','$_POST[cpc]')";
$qsql = mysqli_query($con,$sql);
echo mysqli_error($con);
if(mysqli_affected_rows($con) ==1)
{
echo "<script>alert('Web Advertisement template inserted successfully..');</script>";
echo "<script>window.location='webads.php';</script>";
}
}
}
//2 - Selecting the record starts here..
if(isset($_GET['editid']))
{
$sqledit = "SELECT * FROM webads WHERE webadid='$_GET[editid]'";
$qsqledit = mysqli_query($con,$sqledit);
$rsedit = mysqli_fetch_array($qsqledit);
if($rsedit['advtimg'] == "")
{
$imgname = "img/noimage.jpg";
}
else if(file_exists("imgwebads/$rsedit[advtimg]"))
{
$imgname = "imgwebads/$rsedit[advtimg]";
}
else
{
$imgname = "img/noimage.jpg";
}
}
// 2 - Select the record ends here..
?>
<!-- catg header banner section -->
<section id="aa-catg-head-banner">
<div class="aa-catg-head-banner-area">
<div class="container">
<div class="aa-catg-head-banner-content">
<h2>Checkout Page</h2>
</div>
</div>
</div>
</section>
<!-- / catg header banner section -->
<!-- Cart view section -->
<section id="checkout">
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="checkout-area">
<form action="" method="post" enctype="multipart/form-data" name="frmform" onsubmit="return validateform()">
<div class="row">
<?php
include("sidebar.php");
?>
<div class="col-md-8">
<div class="checkout-left">
<div class="panel-group" id="accordion">
<!-- Billing Details -->
<div class="panel panel-default aa-checkout-billaddress">
<div class="panel-heading">
<h4 class="panel-title">
<a data-parent="#accordion" >
Website Advertisements
</a>
</h4>
</div>
<div id="collapseThree">
<div class="panel-body">
<div class="row">
<div class="col-md-12">
<div class="aa-checkout-single-bill">
Advertisement Title:<span id="idadvttitle" class="errmsg"></span>
<input type="text" value="<?php echo $rsedit['advttitle']; ?>" name="advttitle" placeholder="Advertisement Title ">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="aa-checkout-single-bill">
Advertisement Image:<span id="idadvtimg" class="errmsg"></span>
<input type="file" name="advtimg">
<?php
if($rsedit['advtimg'] != "")
{
?>
<img src="<?php echo $imgname; ?>" >
<?php
}
?>
</div>
</div>
<div class="col-md-12">
<div class="aa-checkout-single-bill">
Advertisement Description:<span id="idadvtdescription" class="errmsg"></span>
<textarea name="advtdescription" placeholder=" Advertisement Description"><?php echo $rsedit['advtdescription']; ?></textarea>
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="aa-checkout-single-bill">
Email ID:<span id="idadvtemail" class="errmsg"></span>
<input type="text" value="<?php echo $rsedit['advtemail']; ?>" name="advtemail" placeholder="Advertisement Email ">
</div>
</div>
<div class="col-md-4">
<div class="aa-checkout-single-bill">
Contact No.:<span id="idcontactno" class="errmsg"></span>
<input type="text" value="<?php echo $rsedit['contactno']; ?>" name="contactno" placeholder="Contact No.">
</div>
</div>
<div class="col-md-4">
<div class="aa-checkout-single-bill">
Website name:<span id="idadvtwww" class="errmsg"></span>
<input type="url" value="<?php echo $rsedit['advtwww']; ?>" name="advtwww" placeholder="example: http://www.companyname.com">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="aa-checkout-single-bill">
Advertisement Address:<span id="idadvtaddress" class="errmsg"></span>
<textarea name="advtaddress" placeholder="Advertisement Address"><?php echo $rsedit['advtaddress']; ?></textarea>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="aa-checkout-single-bill">
Cost per Click (CPC):<span id="idcpc" class="errmsg"></span>
<input type="text" value="<?php echo $rsedit['cpc']; ?>" name="cpc" placeholder="Cost per Click (CPC)">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="aa-checkout-single-bill">
Advertisement Type:<span id="idadvttype" class="errmsg"></span>
<select placeholder="Advertisement type" name="advttype">
<option value="0">Select Status</option>
<?php
$arr = array("Banner Ads","Text Ads");
foreach($arr as $val)
{
if($val == $rsedit['advttype'])
{
echo "<option selected value='$val'>$val</option>";
}
else
{
echo "<option value='$val'>$val</option>";
}
}
?>
</select>
</div>
</div>
<div class="col-md-6">
<div class="aa-checkout-single-bill">
Status:<span id="idstatus" class="errmsg"></span>
<select placeholder="Status" name="status">
<option value="0">Select Status</option>
<?php
$arr = array("Active","Inactive");
foreach($arr as $val)
{
if($val == $rsedit['status'])
{
echo "<option selected value='$val'>$val</option>";
}
else
{
echo "<option value='$val'>$val</option>";
}
}
?>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="aa-checkout-single-bill col-md-6">
<input type="submit" name="submit" value="Click here to Submit" class="aa-browse-btn">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<!-- / Cart view section -->
<?php
include("footer.php");
?>
<script>
function validateform()
{
$('.errmsg').html('');
var checkcondition = "true";
var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
var alphaspaceExp = /^[a-zA-Z\s]+$/;
if(document.frmform.advttitle.value=="")
{
document.getElementById("idadvttitle").innerHTML = "Advertiser title should not be empty..";
checkcondition = "false";
}
if(document.frmform.advtimg.value=="")
{
document.getElementById("idadvtimg").innerHTML = "image file should not be empty..";
checkcondition = "false";
}
if(document.frmform.advtdescription.value=="")
{
document.getElementById("idadvtdescription").innerHTML = "Description should not be empty..";
checkcondition = "false";
}
if(!document.frmform.advtemail.value.match(emailExp))
{
document.getElementById("idadvtemail").innerHTML = "Entered EMail ID is not valid..";
checkcondition = "false";
}
if(document.frmform.advtemail.value=="")
{
document.getElementById("idadvtemail").innerHTML = "Email ID should not be empty..";
checkcondition = "false";
}
if(document.frmform.contactno.value.length != 10 )
{
document.getElementById("idcontactno").innerHTML = "Contact Number should contain 10 digits..";
checkcondition = "false";
}
if(document.frmform.contactno.value=="")
{
document.getElementById("idcontactno").innerHTML = "Contact Number should not be empty..";
checkcondition = "false";
}
if(document.frmform.advtwww.value=="")
{
document.getElementById("idadvtwww").innerHTML = "Website Name should not be empty..";
checkcondition = "false";
}
if(document.frmform.advtaddress.value=="")
{
document.getElementById("idadvtaddress").innerHTML = "Address should not be empty..";
checkcondition = "false";
}
if(document.frmform.cpc.value=="")
{
document.getElementById("idcpc").innerHTML = "Cost per Click should not be empty..";
checkcondition = "false";
}
if(document.frmform.advttype.value=="")
{
document.getElementById("idadvttype").innerHTML = "Type should not be empty..";
checkcondition = "false";
}
if(document.frmform.status.value=="")
{
document.getElementById("idstatus").innerHTML = "Status should not be empty..";
checkcondition = "false";
}
if(checkcondition == "true")
{
return true;
}
else
{
return false;
}
}
</script>