I am trying create a little html email system in a wordpress cms. Given below is the stripped down version of the code I am having currently. It basically grabs the input values and emails them to desired recipients. It was all working fine till I tried to implement an if statement in the code. Please take a look at the php block in the middle.
  $to_whom = strip_tags($_POST ['client_mailid']);
  $to = $to_whom; // no spaces
  $subject = 'some subject here';
  $message = '
  <!DOCTYPE html.....
  <head>head stuff here</head>
  <body>
  <table>
  <tr><td><table>some stuff here</table></td></tr>
  ';?>
  <?php if($_POST['client_input'] !== '') : ?>
  <?php
  '<tr><td>'.$_POST['client_input'].'</td></tr>';?>
  <?php endif;?>
  <?php
  '<tr>
  </table>
  </body>
  </html>
  ';
  $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
  mail($to, $subject, $message, $headers);
  $httpReferer = $_SERVER['HTTP_REFERER'];
  header('Location: '. $httpReferer );
When run this throws an warning below and ignores the redirection, apparent at end of code above. Line 37 as mentioned in warning below contains <?php if($_POST['client_input'] !== '') : ?>. The above code is in a seperate file named single_email.php and is put in a wordpress theme-directroy under the folder email.
Warning: Cannot modify header information - headers already sent by (output started at /home2/xxxx/public_html/xxxxxxxxxxx.com/wp-content/themes/xxxxx/email/single_email.php:37)
So what is going on here, perhaps my php syntax is wrong ? Thanks in advance.
 
     
    