Hello,
I have this code that was migrated from an old website. I need to add a hidden input field so that the users that sign up sign up for the right email list. Below is my code.
<form name="ccoptin" action="http://visitor.constantcontact.com/d.jsp" target="_blank" method="post"> <input type="text" name="ea" size="20" class="cc-input" value=""/> <input type="submit" name="go" value="Go" class="cc-submit"/> <input type="hidden" name="m" value="1105067396888"/> <input type="hidden" name="p" value="oi"/> </form>
Is this even possible? Any help would be appriciated.
Thanks,
Hi,
You can put a simple form like you have on your website to take an email address, and then subsequently send users to your Constant Contact-hosted registration form to complete being added to your account using the method I'm linking to here, but you can't do it all in one step on your website unless you use our Formstack integration or generate an API Key to use our API and write code to perform the contact addition. Here is some sample PHP code that uses our PHP wrapper if you want to go the latter route.
<?php session_start (); require_once 'ConstantContact.php'; require_once 'config.php'; $ConstantContact = new ConstantContact("oauth2", $apiKey, $username, $accessToken); //OR //$ConstantContact = new ConstantContact("basic", $apiKey, $username, $password); //Supply your credentials--API Key and other details--in config.php // Get potential contact lists $lists = $ConstantContact->getLists(); // Lists are returned in multidimentional arrays 0 being the list, and 1 being the next50 // Email address here is used for testing purposes $emailAddress = "testemail11192012@test.com"; // Search for our new Email address $search = $ConstantContact->searchContactsByEmail($emailAddress); //Debugging echo '<pre>'; print_r($ConstantContact); echo '</pre>'; echo $emailAddress . "<br>"; // If the search didnt return a contact object if($search == false) { // Create a new Contact Object to store data into $contactObj = new Contact(); // Adding multiple lists to this new Contact Object $contactObj->lists = array($lists['lists'][0]->id, $lists['lists'][1]->id); // Set the email address $contactObj->emailAddress = $emailAddress; // Create the Contact and DONE $Contact = $ConstantContact->addContact($contactObj); echo ("Contact added."); } // Otherwise we update our existing contact else { // Gather data from our previous search and store it into a data type $contactObj = $ConstantContact->getContactDetails($search[0]); // We need to get the old list and add a new list to it as // this request requires a PUT and will remove the lists // as they are stored in an array array_push($contactObj->lists, $lists['lists'][1]->id ); array_push($contactObj->lists, $lists['lists'][18]->id ); // Update the contact and DONE $UpdateContact = $ConstantContact->updateContact($contactObj); echo ("Contact updated."); } ?>
Best Regards,
Shannon W.
API Support Specialist
The holidays have come and gone. For many seasonal businesses, this means the rush of shoppers has decreased as well. Instead of turning off the lights and waiting for spring, make your email marketi...
See Article