| Server IP : 103.161.17.216 / Your IP : 216.73.216.1 Web Server : nginx/1.18.0 System : Linux tipsysaigoncharming 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 7.4.3-4ubuntu2.29 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/emwin.vn/public/frontend/script/ |
Upload File : |
<?php
/*
Template Name: CafeZone - Coffee responsive HTML template
Variable
$apiKey : Mail Champ Api
$listID : List Id of mail champ
$email : Subscription Email
$fname, $lname, $phone, $subject : You can use these variables when you would add these in your mail champ list form.
*/
function pr($value)
{
echo "<pre>";
print_r($value);
echo "</pre>";
}
if(isset($_POST)){
$dzRes['status'] = 0;
$dzRes['msg'] = '';
/*
You can use these variables when you would add these in your mail champ list form.
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$phone = $_POST['phone'];
$subject = $_POST['subject'];
*/
$email = trim(strip_tags($_POST['dzEmail']));
if(!empty($email) && !filter_var($email, FILTER_VALIDATE_EMAIL) === false){
// MailChimp API credentials
$apiKey = '<!-- Put Your Mail Champ API Key -->';
$listID = '<!-- Put Your Mail Champ List ID -->';
// MailChimp API URL
$memberID = md5(strtolower($email));
$dataCenter = substr($apiKey,strpos($apiKey,'-')+1);
$url = 'https://' . $dataCenter . '.api.mailchimp.com/3.0/lists/' . $listID . '/members/' . $memberID;
// member information
$json = json_encode([
'email_address' => $email,
'status' => 'subscribed'
/*'merge_fields' => [
//'FNAME' => $fname,
//'LNAME' => $lname,
//'PHONE' => $phone,
//'SUBJECT' => $subject,
]*/
]);
// send a HTTP POST request with curl
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_USERPWD, 'user:' . $apiKey);
curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-Type: application/json']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
$result = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
// store the status message based on response code
if ($httpCode == 200) {
$dzRes['status'] = 1;
$dzRes['msg'] = 'You have successfully subscribed.';
} else {
switch ($httpCode) {
case 214:
$msg = 'You are already subscribed.';
break;
default:
$msg = 'Some problem occurred, please try again.';
break;
}
$dzRes['msg'] = $msg;
}
}else{
$dzRes['msg'] = 'Please enter valid email address.';
}
echo json_encode($dzRes);
exit;
}