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
|
<?php require_once ('webadmin/basic_info.php'); require_once('inc/class.phpmailer.php');
$ara = explode("|", $_SESSION['vCode']); $verification = $_POST['verification']; if ($ara[0] == $verification) { $_SESSION['vCode'] = ""; $message = "";
if(empty($_POST["enquiry_for"])){ $message .= "Please select an enquiry issue.\\n\\n"; }
if(empty($_POST["name"])){ $message .= "Please enter your name.\\n\\n"; }
if(empty($_POST["tel"])){ $message .= "Please enter your teletel.\\n\\n"; }else{ if(!is_numeric($_POST["tel"])){ $message .= "Teletel should be digital format.\\n\\n"; } }
if(empty($_POST["email"])){ $message .= "Please enter your email.\\n\\n"; }else{ if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) { $message .= "Invalid email format.\\n\\n"; } }
if(empty($_POST["content"])){ $message .= "Please enter message.\\n\\n"; }
/*if (empty($_POST["g-recaptcha-response"])) { $message .= "Please click the verification box.\\n\\n"; }else{ $url = "https://www.google.com/recaptcha/api/siteverify"; $post_data = array("secret" => $google_recaptcha_secret_key, "response" => $_POST["g-recaptcha-response"]); $result = call_curl($url, $post_data, 1); $result_array = json_decode($result, true); if(!$result_array["success"]){ $message .= "Cannot pass form checking.\\n\\n"; } }*/
if(!empty($message)){ echo "<script>alert('".$message."'); history.back();</script>"; exit; }
//send email $email_subject = "Online Enquiry"; $email_body = '<html> <head> <META name=GENERATOR content="MSHTML 8.00.6001.19394"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style> table td{ padding: 5px; } </style> </head> <body style="font-family:arial,helvetica,sans-serif !important;color:#000;background:#fff; width: 500px;"> Dear Administrator,<br><br>
The following information is an online enquiry.<br><br>
<table style="width: 100%; border-collapse: collapse;"> <tr> <td style="width: 120px;"> Enquiry For: </td>
<td> '.$_POST["enquiry_for"].' </td> </tr>
<tr> <td> Name: </td>
<td> '.$_POST["name"].' </td> </tr>
<tr> <td> Tel.: </td>
<td> '.$_POST["tel"].' </td> </tr>
<tr> <td> E-mail: </td>
<td> '.$_POST["email"].' </td> </tr>
<tr> <td style="vertical-align: top;"> Message: </td>
<td> '.nl2br($_POST["content"]).' </td> </tr>
</table>';
$email_body .= '<br><br><br>' . $site_info{"companyname_en"} . '<br> <a href="' . $site_info{"url"} . '" target="_blank">' . $site_info{"url"} . '</a></body></html>';
/*var_dump($email_body);
exit;*/
$sender_email = $site_info["enquiryemail"]; $company_name = $site_info["companyname_" . $langcode];
//for customer $x_mail = new PHPMailer(); $x_mail->IsSMTP(); $x_mail->Host = 'smtp.mandrillapp.com'; // Specify main and backup server $x_mail->Port = 587; // Set the SMTP port $x_mail->SMTPAuth = true; // Enable SMTP authentication $x_mail->Username = 'garricklam@onesolution.com.hk'; // SMTP username $x_mail->Password = 'lYtE-w6jVOD4vZQrurvraQ'; // SMTP password $x_mail->SMTPSecure = 'tls';
$x_mail->CharSet = "UTF-8"; $x_mail->Sender = $sender_email; $x_mail->AddReplyTo($sender_email, $company_name); $x_mail->From = $sender_email; $x_mail->FromName = $company_name;
//send to user not send to client $x_mail->AddAddress($site_info["enquiryemail"], $site_info["companyname_".$langcode]);
$x_mail->WordWrap = 50; $x_mail->IsHTML(true); $x_mail->Subject = $email_subject; $x_mail->Body = $email_body; if ($x_mail->Send()) { $sent_email = 1; //echo "<script>alert('電郵已成功送出。'); history.back();</script>"; } else { $sent_email = 0; //echo "<script>alert('電郵未能成功送出。'); history.back();</script>"; }
//insert data $sql = "insert into enquiry set enquiry_for=?, name=?, tel=?, email=?, content=?, createdate=?"; $parameters = array($_POST["enquiry_for"], rsa_crypt($_POST["name"],1), rsa_crypt($_POST["tel"],1), rsa_crypt($_POST["email"],1), rsa_crypt($_POST["content"],1), date("Y-m-d")); bind_pdo($sql, $parameters);
header("Location: contact_us_success.php"); }else{ echo "<script type='text/javascript'> alert('Please enter correct verification code.'); history.back(); </script>"; exit; }
|