-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathcontact_process.php
More file actions
93 lines (72 loc) · 2.56 KB
/
contact_process.php
File metadata and controls
93 lines (72 loc) · 2.56 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
<?php
Function ValidateCaptcha($value)
{
// not operational
if (empty($_POST['captcha_entered'])) {
$errors[] = '<p class = "input-error">Please answer the Captcha Question</p>'; return false;
} elseif ($_REQUEST['captcha_entered']!=$_SESSION['rand_code']) {
$errors[] = '<p class = "input-error">Your answer to the Math Question is incorrect.</p>'; return false;
}
Return true;
}
function ValidateEmail($value)
{
$regex = '/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i';
if($value == '') {
return false;
} else {
$string = preg_replace($regex, '', $value);
}
return empty($string) ? true : false;
}
include 'settings.php';
$domain= $_SERVER['SERVER_NAME'];
// $url= $_SERVER['SERVER_NAME'];
// $domain = str_ireplace('www.', '', parse_url($url, PHP_URL_HOST));
// echo $domain;
$post=TRUE;
// echo $post;
if($post){
$name = stripslashes($_POST['name']);
$message = stripslashes($_POST['message']);
$email = stripslashes($_POST['email']);
$subject = $domain.' Domain Sale Inquiry';
$error = '';
$emailbody = '<html><head><title>Request</title></head>';
$emailbody .='<body>';
$emailbody .='<p>name: '.$name.'</p>';
$emailbody .='<p>message: '.$message.'</p>';
$emailbody .='<p>email : '.$email.'</p>';
$emailbody .='</body></html>';
// if the titles have Russian letters - they need to be encoded , because
// in the Content-Type specifies the encoding of the body only , which can be sent in any encoding .
// it is necessary for normlano display and OUTLOOK THE BAT
$name = '=?UTF-8?B?'.base64_encode($name).'?=';
$subject = '=?UTF-8?B?'.base64_encode($subject).'?=';
if (!ValidateEmail($email)){
$error = '<p class="bg-danger">email format is not correct! </p>';
}
if(!$error){
$date = new DateTime();
$currentdate = $date->format('Y-m-d H:i:s');
$subject .= " / ".$currentdate;
/* Working
$mail = mail(CONTACT_FORM, $subject, $emailbody,
"From: ".$name." <".$email.">\r\n"
."Reply-To: ".$email."\r\n"
."Content-type: text/html; charset=utf-8 \r\n"
."X-Mailer: PHP/" . phpversion());
*/
$mail = mail(CONTACT_FORM, $subject, $emailbody,
"From: Domain Sale Form <".CONTACT_FORM.">\r\n"
."Reply-To: ".CONTACT_FORM."\r\n"
."Content-type: text/html; charset=utf-8 \r\n"
."X-Mailer: PHP/" . phpversion());
if($mail){
echo '<div class="bg-danger">'."Thank you! Your email has been sent".'</div>';
}
}else{
echo '<div class="bg-danger">Error: '.$error.'</div>';
}
}
?>