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




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 ...
      ... send them to a failure page here ...


If you have any questions please let me know.



Benjamin Soder
NOC Analyst
Constant Contact
Occasional Participant

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


    $ccContactOBJ = new CC_Contact();
    $ccListOBJ = new CC_List();

    $contactXML =
<entry xmlns="">
  <title type="text"> </title>
  <summary type="text">Contact</summary>
  <content type="application/vnd.ctct+xml">
    <Contact xmlns="">
        <ContactList id="" />
    if (!$ccContactOBJ->addSubscriber($contactXML)) {

else {

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




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.



Benjamin Soder
NOC Analyst
Constant Contact
Occasional Participant

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.

Developer Portal

View API documentation, code samples, get your API key.

Visit Page