0

someone kindly posted this code for me but it only returns "/table" in the resulting email - any ideas? Does it need a closing html tag?

$mailHeader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$formcontent ="<table border='1'>";
foreach ($_POST as $field=>$value)
{
$formcontent.="<tr>";
$formcontent .= "<td>$field:</td> <td>$value</td>";
$formcontent.="</tr>";
}
$formcontent .= '<tr><td>User-Agent: </td><td>'.$_SERVER['HTTP_USER_AGENT'].'</td>';
$formcontent ="</table>";
2
  • 2
    Don't build your own mime emails. It's tricky and very easy to screw up. Using PHPMailer or Swiftmailer, both of which make it a trivial process. Commented Jun 18, 2012 at 21:15
  • Hi Marc - not familiar with Swiftmailer but will google it - thanks Commented Jun 18, 2012 at 21:16

1 Answer 1

5

The final line is currently:

$formcontent ="</table>";

It should be:

$formcontent .="</table>";

Without the dot, it's overwriting the content, rather than concatenating.

Sign up to request clarification or add additional context in comments.

2 Comments

Ah - my ignorance of PHP shining through I'm afraid - thanks very much for your help -
You're welcome - it's one of those things that's obvious when you know it's there. A fresh pair of eyes helps no end!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.