You Are Subscribed

[insert_php]

echo “

Thank you for signing up for the CANTASD mailing list!

“;
$curl = curl_init();
$fname = $_POST[“fname”];
$lname = $_POST[“lname”];
$email = $_POST[“email”];
curl_setopt_array($curl, array(
CURLOPT_URL => “https://api.sendgrid.com/v3/contactdb/recipients”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “[\n {\n \”email\”: \”$email\”,\n \”first_name\”: \”$fname\”,\n \”last_name\”: \”$lname\”\n }\n]”,
CURLOPT_HTTPHEADER => array(
“authorization: Bearer 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”,
“cache-control: no-cache”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);

if ($err) {
echo “cURL Error #:” . $err;
} else {

$json = json_decode($response, true);
$contactarray = $json[“persisted_recipients”];
$newcontact = $contactarray[0];

$curl = curl_init();
$fname = $_POST[“fname”];
$lname = $_POST[“lname”];
$email = $_POST[“email”];
curl_setopt_array($curl, array(
CURLOPT_URL => “https://api.sendgrid.com/v3/contactdb/lists/541361/recipients/{$newcontact}”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “[\n {\n \”email\”: \”$email\”,\n \”first_name\”: \”$fname\”,\n \”last_name\”: \”$lname\”\n }\n]”,
CURLOPT_HTTPHEADER => array(
“authorization: Bearer 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”,
“cache-control: no-cache”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);

$aTopic = $_POST[‘formTopic’];

if(empty($aTopic))
{

echo(“

You didn’t select any topics.

“);
}
else
{
$N = count($aTopic);

echo(“

You selected $N Topic(s):

“);

for($i=0; $i < $N; $i++) { echo($aTopic[$i] . " "); echo "
“;
}
}

if(IsChecked(‘formTopic’,’Community Engagement’))
{
$curl = curl_init();
$fname = $_POST[“fname”];
$lname = $_POST[“lname”];
$email = $_POST[“email”];
curl_setopt_array($curl, array(
CURLOPT_URL => “https://api.sendgrid.com/v3/contactdb/lists/1471061/recipients/{$newcontact}”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “[\n {\n \”email\”: \”$email\”,\n \”first_name\”: \”$fname\”,\n \”last_name\”: \”$lname\”\n }\n]”,
CURLOPT_HTTPHEADER => array(
“authorization: Bearer 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”,
“cache-control: no-cache”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
}
if(IsChecked(‘formTopic’,’Families Impacted by Incarceration’))
{
$curl = curl_init();
$fname = $_POST[“fname”];
$lname = $_POST[“lname”];
$email = $_POST[“email”];
curl_setopt_array($curl, array(
CURLOPT_URL => “https://api.sendgrid.com/v3/contactdb/lists/1471058/recipients/{$newcontact}”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “[\n {\n \”email\”: \”$email\”,\n \”first_name\”: \”$fname\”,\n \”last_name\”: \”$lname\”\n }\n]”,
CURLOPT_HTTPHEADER => array(
“authorization: Bearer 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”,
“cache-control: no-cache”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
}
if(IsChecked(‘formTopic’,’Father Engagement’))
{
$curl = curl_init();
$fname = $_POST[“fname”];
$lname = $_POST[“lname”];
$email = $_POST[“email”];
curl_setopt_array($curl, array(
CURLOPT_URL => “https://api.sendgrid.com/v3/contactdb/lists/1471072/recipients/{$newcontact}”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “[\n {\n \”email\”: \”$email\”,\n \”first_name\”: \”$fname\”,\n \”last_name\”: \”$lname\”\n }\n]”,
CURLOPT_HTTPHEADER => array(
“authorization: Bearer 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”,
“cache-control: no-cache”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
}
if(IsChecked(‘formTopic’,’Neglect’))
{
$curl = curl_init();
$fname = $_POST[“fname”];
$lname = $_POST[“lname”];
$email = $_POST[“email”];
curl_setopt_array($curl, array(
CURLOPT_URL => “https://api.sendgrid.com/v3/contactdb/lists/1471143/recipients/{$newcontact}”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “[\n {\n \”email\”: \”$email\”,\n \”first_name\”: \”$fname\”,\n \”last_name\”: \”$lname\”\n }\n]”,
CURLOPT_HTTPHEADER => array(
“authorization: Bearer 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”,
“cache-control: no-cache”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
}
if(IsChecked(‘formTopic’,’Prevention Planning’))
{
$curl = curl_init();
$fname = $_POST[“fname”];
$lname = $_POST[“lname”];
$email = $_POST[“email”];
curl_setopt_array($curl, array(
CURLOPT_URL => “https://api.sendgrid.com/v3/contactdb/lists/1471151/recipients/{$newcontact}”,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => “”,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_CUSTOMREQUEST => “POST”,
CURLOPT_POSTFIELDS => “[\n {\n \”email\”: \”$email\”,\n \”first_name\”: \”$fname\”,\n \”last_name\”: \”$lname\”\n }\n]”,
CURLOPT_HTTPHEADER => array(
“authorization: Bearer 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”,
“cache-control: no-cache”
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
}
}

function IsChecked($chkname,$value)
{
if(!empty($_POST[$chkname]))
{
foreach($_POST[$chkname] as $chkval)
{
if($chkval == $value)
{
return true;
}
}
}
return false;
}

[/insert_php]