cancel
Showing results for 
Search instead for 
Did you mean: 
Constant Contact wants to help you succeed! We’re celebrating our professional service programs on the Constant Contact Community this month and you have a chance to try one of the services for free! Learn more.

Redirecting after transferring data

Occasional Participant

Redirecting after transferring data

I am integrating cc into a contact form.

Using cc_class.php I was able to successfully create a new contact.  

How do I redirect to a thank you page after completing the data transfer?

Sending the data as XML already outputs a header.

Sending another header for redirection isn't permitted.

 

Thank you Michael

4 REPLIES 4
CTCT Employee

Re: Redirecting after transferring data

Hello,

 

The way that our cc_class.php file works is that once you call the addSubscriber function, it will return a success or fail code to you.  What you would want to do is have an if statement that goes:

 

$returned_code = addSubscriber($contactXML);

if ($returned_code == 201)
   {
      ... send them to a success page here ...
   }
else
   {
      ... send them to a failure page here ...
   }

 

If you have any questions please let me know.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Occasional Participant

Re: Redirecting after transferring data

This is my code. I get an error that the heading has already been sent.

 

include($_SERVER['DOCUMENT_ROOT'].'/application/library/cc_class.php');
    $ccContactOBJ = new CC_Contact();
    $ccListOBJ = new CC_List();

    $contactXML =
    '
<entry xmlns="http://www.w3.org/2005/Atom">
  <title type="text"> </title>
  <updated>2008-07-23T14:21:06.407Z</updated>
  <author></author>
  <id>data:,none</id>
  <summary type="text">Contact</summary>
  <content type="application/vnd.ctct+xml">
    <Contact xmlns="http://ws.constantcontact.com/ns/1.0/">
      <EmailAddress>'.$email.'</EmailAddress>
      <OptInSource>ACTION_BY_CONTACT</OptInSource>
      <ContactLists>
        <ContactList id="http://api.constantcontact.com/ws/customers/asmithinvt/lists/1" />
      </ContactLists>
    </Contact>
  </content>
</entry>
    ';
   
    if (!$ccContactOBJ->addSubscriber($contactXML)) {
   //nothing
     
     }


else {

 header("location: ".HTTPABSOLUTEPATH."index.php?go=thankyou");

}

CTCT Employee

Re: Redirecting after transferring data

Hello,

 

You normally get that error if you have already sent the header in your file.  Our cc_class file does not use the header function at all, so it would have to be somewhere already in another piece of your code.

 

If you want, you can send us the entire code here, we can take a look to see if we can get it running.

 

Regards,

Benjamin Soder
NOC Analyst
Constant Contact
Occasional Participant

Re: Redirecting after transferring data

I figured it out. I was getting the error even if I only included the cc_class.php file.

Erasing the file, creating a new one and pasting the contents off cc_class.php into it fixed it.

Not sure what the exact problem was, but I'm assuming there was type of character set/file format issue.