AMJ Mailing List
success; // store validation result to a variable.
if (!$captcha_status || $response==””) {
// What happens when the CAPTCHA was entered incorrectly
$form_error=”The CAPTCHA wasn’t entered correctly. Please try again.”;
$status=-2;
}
}
//$status=0 -> captcha is valid
if ( ‘POST’ === $_SERVER[‘REQUEST_METHOD’] && $status==0){
$status=-1;
//prepare data
//url-ify the data for the POST
$fields = array();
foreach($_POST as $key=>$value) { $fields[] = $key.’=’.urlencode($value); }
$fields_string = implode(‘&’, $fields);
$fields_string .= ‘&list%5B11%5D=signup&listname%5B2%5D=AMJ+Messaging+Service+Subscription’;
#echo $fields_string;
//$url = ‘https://contact.ahmadiyya.ca/lists/?p=subscribe&id=1’;
$url = ‘http://contact.ahmadiyya.ca/lists/?p=subscribe&id=1’;
//open connection
$ch = curl_init();
//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYSTATUS, 0);
$form_result = curl_exec($ch);
#echo “\nFORM__RESULT\n”;
#echo $form_result;
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if(curl_errno($ch) || $httpcode != “200”)
{
error_log (‘List add error:’ . curl_error($ch));
$info=curl_getinfo($ch);
error_log(“info:” . implode(“\n”,$info));
$status=0;
$form_error=”We were unable to register your email due to a system error. Please contact admin@ahmadiyya.ca“;
}else{
$success_string=’/.h3.Thank you for subscribing to our newsletters…h3./’;
if(preg_match($success_string,$form_result)){
$status=1;
}else{
$form_error=”We were unable to register your email due to a system error. Please contact admin@ahmadiyya.ca“;
}
}
//close connection
curl_close($ch);
//exit(0);
}
?>
if ($status==1) {?>
Mailing List
Thank you for subscribing to our newsletters.
Your email address has been added to our system.
You will receive a message with a request to confirm your membership.
Please make sure to click the link in that message to confirm your subscription.
} else {?>
Keep yourself informed of upcoming events.
Enter your email address below to subscribe to
Ahmadiyya.ca mailing list.
Note: All fields with (*) are required
All field with labels in red text are required fields.
} ?>
“. $form_error.”“;
?>
if ($status==0 || $status==-2) {?>
}?>
Friday Sermon
Prayer Timings
| Fajr | |
| Sunrise | |
| Zuhr | |
| ´Asr | |
| Sunset | |
| Maghrib | |
| ´Ishaa´ |