-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontact-form.php
290 lines (129 loc) · 5.47 KB
/
contact-form.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
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
<?
if (!$_SESSION)
{
session_start();
}
$name=$_REQUEST['name'];
$mail=$_REQUEST['mail'];
$phone=$_REQUEST['phone'];
$occupation=$_REQUEST['occupation'];
$des=$_REQUEST['com'];
$captcha = $_REQUEST['sco'];
$captcha_check_value = $_SESSION['captcha_a'];
//$pattern = "/[.]+(aero|arpa|asia|biz|cat|com|coop|edu|gov|info|int|jobs
//|mobi|mil|museum|name|net|org|pro|root|tel|travel|ac
//|ad|ae|af|ag|ai|al|am|an|ao|aq|ar|as|at|au|aw|ax|az
//|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bw|by
//|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cx
//|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|er|es|et|eu|fi|fj
//|fk|fm|fo|fr|ga|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr
//|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|htm|html|php|il|im|in|io|iq
//|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kr|kw|ky|kz|la
//|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mk|ml|mm
//|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|asp|cgi
//|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk
//|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd
//|se|sg|sh|si|sk|sl|sm|sn|sr|st|sv|sy|sz|tc|td|tf|tg|th
//|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|us|uy|uz|va
//|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw|levitra|viagra|casino|sex|loan|finance|slots|debt|free|html)$/i";
//$http = substr_count($des, "http");
//$href = substr_count($des, "href");
//$url = substr_count($des, "[url");
//$www = substr_count($des, "www");
//$httphrefurl = $http + $href + $url + $www;
//$http_web = substr_count($web, "http://");
$a_name = count(explode(" ",$_REQUEST[name]));
$b_name = strlen($name);
$c_name = str_word_count($name);
include 'check_spl_char.php';
$ch_name = checkSplChar($name);
$a_des = str_word_count($des);
//$b_des = strlen($des);
include 'get_real_ip.php';
$ip = getIP();
//------------- Name Checking --------------
if(($name == '') || ($c_name == 0)){
$cont_error = "Error! Plz enter your name.";
}elseif($a_name > 2){
$cont_error = "Error! More than a space is not allowed on the name field.";
}elseif($b_name > 21){
$cont_error = "Error! Name consists of maximum 21 characters.";
}elseif($ch_name == 0){
$cont_error = "Error! Special characters are not allowed on the name field.";
}
//------------- Email ID Checking --------------
elseif($mail == ''){
$cont_error = "Error! Please enter an e-mail id.";
}elseif(!filter_var($_REQUEST[mail], FILTER_VALIDATE_EMAIL)){
$cont_error = "Error! The e-mail you entered was not in the proper format.";
}
//------------- Website URL checking -------------
//--------------- Comment checking---------------
elseif(($des == '') || ($a_des == 0)){
$cont_error = "Error! Comment cannot be blank.";
}
elseif($a_des > 250){
$cont_error = "Error! Comment consists of maximum 250 words.";
}
//------------- Spam comment checking ------------
//elseif (($des != '') && (preg_match($pattern, $des))){
//$cont_error = "Error! Comment looks a bit spammy. Rewrite it please.";
//}
//elseif (($des != '') && ($http > 0 OR $href > 0 OR $url > 0 OR $www > 0 OR $httphrefurl > 0)){
//$cont_error = "Error! Comment looks a bit spammy. Rewrite it please.";
//}
// Get the IP/ensure that what we have is a real IP
elseif(($ip == '') || ($ip == 'unknown'))
{
$cont_error = "Error! IP not found. Rewrite it please.";
}
//------------- Security Code Checking --------------
elseif(($captcha == '') || ($captcha == 'Enter the security code')){
unset($captcha_check_value);
$cont_error = "Error! Please enter the security code.";
}elseif($captcha != $captcha_check_value){
unset($captcha_check_value);
$cont_error = "Error! Please enter the security code correctly.";
}
else{
//------------------------------------- Please change the matter =----------------------------------
$headers .= "From:" . $name . "<" .$mail . ">" ."\r\n";
$headers .= "Holi Child School Burdwan - ".$name." Website Enquiry Form";
$to="[email protected]";
$message ="Name = $name\nEmail = $mail\nPhone = $phone\nOccupation = $occupation\nComments = $des\n";
if(mail($to,"Holi Child School Burdwan - Feedback Form",$message,$headers)) {
$contact_msg = "Message Sent. We will respond very soon. Thanks";
$name='';
$mail='';
$phone='';
$occupation='';
$des='';
} else {
$cont_error = "There was a problem sending the mail. Please contact to [email protected]";
}
}
?>
<?
if($contact_msg != ''){
echo "<span style=\"color:#FF0000\">".$contact_msg."</span><br>";
}else{
?>
<FORM name="ajax" method="POST" action="">
<?
if($cont_error != ''){
echo "<span style=\"color:#FF0000; font-size:15px\">".$cont_error."</span><br>";
}
?>
<input name="name" type="text" id="name" maxlength="30" class="formin1" value="<?=$name;?>" placeholder="Your Name">
<input type="hidden" name="dyn" size="32" value="">
<input name="mail" type="text" maxlength="255" class="formin1" id="mail" value="<?=$mail;?>" placeholder="Email Address">
<input name="phone" type="text" maxlength="255" class="formin1" id="phone" value="<?=$phone;?>" placeholder="Mobile Number">
<input name="occupation" type="text" maxlength="255" class="formin1" id="occupation" value="<?=$occupation;?>" placeholder="Occupation">
<textarea rows="2" name="com" cols="55" class="formin1" id="com" placeholder="Comments"><?=$des;?></textarea>
<img src="/captcha.php" alt=""><br>
<input type="text" name="sco" id="sco" maxlength="30" class="formin1" placeholder="Security Code">
<INPUT type="BUTTON" value="Submit" ONCLICK="submitForm()" alt="" class="contact-btn">
</FORM>
<?
}
?>