Adding subscription to Create_account php


#1

I have managed to create the subscribe/unsubscribe form and it works fine sending confirmation emails and once confirmed adding the users to the announcement list.
I need integrate the newsletter checkbox on my create account page so that is also sends the confirmation email in addition to the “welcome letter”.
It actually worked once yesterday and I thought I had it figured out but today it isn’t working again. I found most of this in other discussion posts and from internet research so you may recognize it. I added the code after the php code updates the customer table in the databse. zen_db_perform(TABLE_CUSTOMERS, $sql_data_array);

This is the code I added to the create_account.php file
//** add code to send info to announcement list at Dreamhost changing variable subscribeMe to newsletter zen-variable
if(isset($_POST[‘newsletter’]) && $_POST[‘newsletter’] == 1)
{
//get the values we need from form(this should in aprt already be somewhere in the code your editing)
$address=$_POST[‘email_address’];
$fullName=$_POST[‘firstname’]." ".$_POST[‘lastname’];
//set values we should know, and are constant
$api_domain=“mydomain.com”;
$api_listname=announcements;
$apiKey=“my key”;

	$ch = curl_init('https://api.dreamhost.com/');
	curl_setopt ($ch, CURLOPT_POST, true);  	
	curl_setopt ($ch, CURLOPT_POSTFIELDS, "key=$apiKey&cmd=announcement_list-add_subscriber&listname=$api_listname&domain=$api_domain&email=$address&name=$fullName");
	
	$result=curl_exec ($ch);
	curl_close ($ch);

	if ( $result!==false && stripos( $result,’success’)!==false){
		echo "<h2>Congrats! </h2><p>You have been added to our Email Announcement List</p>";
	}else{
		echo "<h2> Ooops! </h2><p>Unable to add your email to our announcement list please contact site administrator.</p>";
		echo "Code: " . $result;
	}

}// end if subscribe box checked

I removed my domain name and api key but can make them available if needed.
I know I’m missing something and appreciate any help you can give.


#2

sorry,
I was missing something. I kept deleting the subscriptions from the announcement list and using the same addresses over and over. Apparently there is a time delay and the addresses were still in the system therefore the announcement list was not sending out duplicate confirmation email.
Sorry for this confusion. I set up bunch of dummy email addresses and tested with them. Everything is now working beautiful.