the headers already sent error is caused by having output on the page before the header function is called.
in your case, you have the code for the ecart add to cart button behavior in the HTML body of the page.
the add to cart button code should be in the head of the page before the doctype tag, not in the HTML body.
by adding it in the HTML body, there is already HTML output to the page before the add to cart button calls the header function to perform the redirect. this is causing the error.