Skip to content Skip to sidebar Skip to footer

How To Send Values From Html Form To Mail In Table PHP

This what I have I tried to put it in a table just like:
$_POST['onderwerp']
This is what I have it sends t

Solution 1:

<?php
$to = 'user@example.com';
$subject = 'Vraag via de website';
$msg = "<html>
 <head>
 <title>Title of email</title>
 </head>

 <body>

<table cellspacing=\"4\" cellpadding=\"4\" border=\"1\" align=\"center\">

<tr>
<td align=\"center\">Onderwerp</td>
<td align=\"center\"> vraag</td>
<td align=\"center\">Telefoonummer</td>
<td align=\"center\">Email</td>
</tr>

<tr>
<td align=\"center\">".$_POST['onderwerp']."</td>
<td align=\"center\">".$_POST['vraag']."</td>
<td align=\"center\">".$_POST['tel']."</td>
<td align=\"center\">".$_POST['email']."</td>
</tr>



</table>
</body>
</html>";

// Make sure to escape quotes

$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: My Site Name <me@mysite.com>' . "\r\n";

mail($to, $subject, $msg, $headers);

?> 

Solution 2:

you could try this using your variables.

$var = 'test';
$var2 = 'test2';

echo '<table border="1">';
echo '<tr><td>' . $var . '</td></tr>';
echo '<tr><td>' . $var . '</td></tr>';
echo '</table>';

this will show the variables in a table, then you can edit the table using css how you want. :)


Solution 3:

I suggest that you include swiftmailer. Swiftmailer makes sure emails get delivered in the Inbox and you can easily include HTML markup in your emails:

Swiftmailer HTML in email

Just download the Swiftmailer Library, include and configure it like this example:

Sending an email in swiftmailer

Let me know if this helps you out!


Post a Comment for "How To Send Values From Html Form To Mail In Table PHP"