I am having trouble getting the first name, last name, and phone number transferred from our web forms to CC. The code I am using is below. The email address is successful but the other info is left out. Any help would be appreciated.
// Check to see which form this came from and assign the POST variable to a local variable //MCS Registrations First if (isset($_POST["this_form"]) && $_POST["this_form"] == "http://www.swcdi.org/MCS-Reg-1.htm") { $firstName = $_POST["Contact_First_Name"]; $lastName = $_POST["Contact_Last_Name"]; $homePhone = $_POST["Emergency_Phone"]; $emailAddress = $_POST["Email_Address"]; } //Now do the "contact us" form if (isset($_POST["this_form"]) && $_POST["this_form"] == "http://www.swcdi.org/contact.htm") { $firstName = $_POST["First_Name"]; $lastName = $_POST["Last_Name"]; $homePhone = $_POST["eve_phone"]; $emailAddress = $_POST["email_address"]; } // Search for our new Email address $search = $ConstantContact->searchContactsByEmail($emailAddress); // If the search didnt return a contact object... if($search == false) { // Create a new Contact Object to store data into $contactObj = new Contact(); // Adding lists to this new Contact Object $contactObj->lists = array($lists['lists'][0]->id); // Set the properties for the contact object $contactObj->firstName = $firstName; $contactObj->lastName = $lastName; $contactObj->homePhone = $homePhone; $contactObj->emailAddress = $emailAddress; // Create the Contact and DONE $Contact = $ConstantContact->addContact($contactObj); } // Otherwise we update our existing 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'][0]->id ); // Update the contact and DONE $UpdateContact = $ConstantContact->updateContact($contactObj); }
Hey Joshua,
I'm not seeing any immediate issues with how you're using the wrapper. I would be interested if we could get the value of $firstName before sending it through the function, either by echoing or checking if it is empty. Just as a quick example:
if(empty($firstName)) { die(); } else { echo $firstName; }
If we can see the value that's trying to go through, we can definitely test some things out with it.
I just ran that bit of code you suggested to test if a value was transferred from the POST array to the local variable $firstName. It completed and returned the appropriate value.
Just for fun I checked the values of the other local variables and they all returned correct values.
It must be somewhere with how I am assigning those variables to the parameters of the new contact object. Thoughts?
Any thoughts...I still can't get this working. The email goes through just fine bu the additional information does not show up in the contact.
Hey Joshua,
I'd be interested in seeing the contact details of an email address before you pass it through this form. Are you using a completely new contact to the account? A removed contact would also retain some information, so the best troubleshooting step I can think of at this point (unless the contacts you are pushing through the form are already fresh to the account) would be to send through a completely fresh entry, and see if you get the same results.
Depending on the outcome of that test, I might just ask you to zip up your files and email them to us, so I can do the testing with the same environment you're working in.
Yes..even with a completely fresh contact the email adds correctly but the rest of the info is lost.
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