// NOT FROM BEFORE 1:14 HAH
//bust the cache
header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Pragma: no-cache" );
/// *** CUSTOMER DATA *** ///
// List our lists
$list_array = array("Tips, Tools, & Strategies");
/// *** CUSTOMER DATA *** ///
// Page content
$page_content = "This is your page content; please update these part.";
//Validate email address & check that the form is submitted
if (isset($_POST["checksubmit"])) {
/// *** CUSTOMER DATA *** ///
//Constant Contact login
$username = "lynnrey";
$password = "HoneyFluffy2";
// Is this a subscribe or unsubscribe?
if (isset($_POST["unsub_request"]) && $_POST["unsub_request"] == "1") $url = "http://api.constantcontact.com/0.1/API_UnsubscribeSiteVisitor.jsp";
else $url = "http://api.constantcontact.com/0.1/API_AddSiteVisitor.jsp";
// Constant form data
$data = "loginName=" . $username;
$data .= "&loginPassword=" . $password ;
$data .= "&ea=" . urlencode(strip_tags($_POST["email"]));;
if (isset($_POST["First_Name"])) $data .= "&First_Name=" . urlencode(strip_tags($_POST["First_Name"]));
if (isset($_POST["Last_Name"])) $data .= "&Last_Name=" . urlencode(strip_tags($_POST["Last_Name"]));
//if (isset($_POST["Work_Phone"])) $data .= "&Work_Phone=" . urlencode(strip_tags($_POST["Work_Phone"]));
//if (isset($_POST["Address_Line_1"])) $data .= "&Address_Line_1=" . urlencode(strip_tags($_POST["Address_Line_1"]));
//if (isset($_POST["City"])) $data .= "&City=" . urlencode(strip_tags($_POST["City"]));
//if (isset($_POST["State"])) $data .= "&State=" . urlencode(strip_tags($_POST["State"]));
//if (isset($_POST["Postal_Code"])) $data .= "&Postal_Code=" . urlencode(strip_tags($_POST["Postal_Code"]));
// For each submitted list, we run through these actions.
foreach($_POST["list_name"] as $list_name) {
// Unique list for each loop iteration
if ($list_name) $list_data = "&ic=" . urlencode(strip_tags($list_name));
//If the form was submitted, and the email is valid, then POST via libcurl
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$url); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
curl_setopt($ch, CURLOPT_POST, 1); // set POST method
curl_setopt($ch, CURLOPT_POSTFIELDS, $data . $list_data); // add POST fields
$cc_result = curl_exec($ch); // run the whole process
curl_close($ch);
// Create an array of the response values
$details = explode("\n",$cc_result);
// NEED ERROR CHECKING CODE HERE
//echo $cc_result;
}
if (isset($_POST["unsub_request"]) && $_POST["unsub_request"] == "1") {
if ($details[0] == "0") echo "You've been removed.";
// NEED ERROR CHECKING CODE HERE
else if ($details[0] == "500") echo "There was a problem removing you: " . $details[1];
}
else {
if (isset($_POST["User_Name"]) && $_POST["User_Name"] != "") $name_html = ", " . $_POST["User_Name"];
if ($details[0] == "0") include('success.php');
else if ($details[0] == "500") include('fail.php');
}
}
// Either the form was not sent yet, or the email was bad
else {
// If the form was sent, it means the email address was invalid
// Show page content
$page_content;
/// *** CUSTOMER DATA *** ///
// Print the form, including original values if tried to process at least once before
}
?>
Profitable Employee Solutions - Fast Answers to Your Employee Problems