i want to use to html table in a php variable so that i can use that variable in php mail and that mail should renders the html table. I used EOD but its not working. Here is the code i'm using which is not working.
$body1 = <<<EOD
<br><br>
<h3 align="center">Career Details</h3>
<table border="1" width="100%">
<col width="50%">
<col width="50%">
<tr>
<td style="text-align:left;">Name: $nameField </td>
<td style="text-align:left;">Email: $emailField </td>
</tr>
<tr>
<td style="text-align:left;">Date of Birth: $dob</td>
<td style="text-align:left;">Passport Number: $passportnum</td>
<tr>
<td style="text-align:left;">Gender: $gender</td>
<td style="text-align:left;">Nation: $nation</td>
<tr>
<td style="text-align:left;">Phone: $phone</td>
<td style="text-align:left;">Prefered Location: $location</td>
<tr>
<td style="text-align:left;">Area of Interest: $areaofinterest</td>
</table>
EOD;
$body=$body1;
$headers = 'From: noreply@mydomain.com';
if(mail($mailto, $emailSubject, $body, $headers)){
header ('Location: http://www.mydomain.net?page_id=664');
}
The space before EOD;
. It needs to be on its own line, without any space before it. Example:
$body1 = <<<EOD
yourstuff
EOD; // Note that there is no space before EOD;.
The closing identifier must begin in the first column of the line.
You need to improve your sensible indentation and manual reading skills.
From the php manual:
It is very important to note that the line with the closing identifier must contain no other characters, except possibly a semicolon (;). That means especially that the identifier may not be indented, and there may not be any spaces or tabs before or after the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by the local operating system. This is on UNIX systems, including Mac OS X. The closing delimiter (possibly followed by a semicolon) must also be followed by a newline.
If this rule is broken and the closing identifier is not "clean", it will not be considered a closing identifier, and PHP will continue looking for one. If a proper closing identifier is not found before the end of the current file, a parse error will result at the last line.
Also you have to fix your html table(note `</tr>
` is missing in your code):
$body1 = <<<EOD
<br><br>
<h3 align="center">Career Details</h3>
<table border="1" width="100%">
<col width="50%">
<col width="50%">
<tr>
<td style="text-align:left;">Name: $nameField </td>
<td style="text-align:left;">Email: $emailField </td>
</tr>
<tr>
<td style="text-align:left;">Date of Birth: $dob</td>
<td style="text-align:left;">Passport Number: $passportnum</td>
</tr>
<tr>
<td style="text-align:left;">Gender: $gender</td>
<td style="text-align:left;">Nation: $nation</td>
</tr>
<tr>
<td style="text-align:left;">Phone: $phone</td>
<td style="text-align:left;">Prefered Location: $location</td>
</tr>
<tr>
<td style="text-align:left;">Area of Interest: $areaofinterest</td>
</tr>
</table>
EOD;