我有一个表格,人们可以填写详细信息并分享他们当前的时间表。然后我去寻找适合人们的时间并将它们分组。
目前,PHP表单将“工作”或“免费”变量(根据其在表单中的选择)打印到表格中,然后发送包含联系方式和时间表的电子邮件。
发送表单时,是否可以为表格的特定单元格指定文本颜色或单元格颜色值? (因此,当我收到电子邮件时,其中带有“免费”变量的单元格将显示为绿色等。)
<?php
$name_f = $_POST['name_f'];
$name_l = $_POST['name_l'];
$phne = $_POST['phne'];
$cont_em = $_POST['cont_em'];
$MON09TO10H = $_POST['MON09TO10H'];
$TUE09TO10H = $_POST['TUE09TO10H'];
$WED09TO10H = $_POST['WED09TO10H'];
...
$to = "email@email.com";
$subject = "New Message";
...
$message = <<<EOD
New Form Submitted<br><br>
<b>Name:</b> $name_f $name_l <br>
<b>Phone:</b> $phne <br>
<b>Email:</b> $cont_em <br>
<table border="1">
<tr><!-- Row 1 -->
<td></td><!-- Col 1 -->
<td><span class="table_header">Monday</span></td><!-- Col 2 -->
<td><span class="table_header">Tuesday</span></td><!-- Col 3 -->
<td><span class="table_header">Wednesday</span></td><!-- Col 4 -->
<td><span class="table_header">Thursday</span></td><!-- Col 5 -->
<td><span class="table_header">Friday</span></td><!-- Col 6 -->
</tr>
<tr><!-- Row 2 -->
<td style="width:140px">9 to 10 AM</td><!-- Col 1 -->
<td style="width:140px; height:40px">$MON09TO10H</td><!-- Col 2 -->
<td style="width:140px; height:40px">$TUE09TO10H</td><!-- Col 3 -->
<td style="width:140px; height:40px">$WED09TO10H</td><!-- Col 4 -->
<td style="width:140px; height:40px">$THU09TO10H</td><!-- Col 5 -->
<td style="width:140px; height:40px">$FRI09TO10H</td><!-- Col 6 -->
</tr>
<tr><!-- Row 3 -->
<td>10 to 11 AM</td><!-- Col 1 -->
<td style="width:140px; height:40px">$MON10TO11H</td><!-- Col 2 -->
<td style="width:140px; height:40px">$TUE10TO11H</td><!-- Col 3 -->
<td style="width:140px; height:40px">$WED10TO11H</td><!-- Col 4 -->
<td style="width:140px; height:40px">$THU10TO11H</td><!-- Col 5 -->
<td style="width:140px; height:40px">$FRI10TO11H</td><!-- Col 6 -->
</tr>
...
</table>
EOD;
// Send the mail
if (isset($_POST['send']))
{
$sent = mail($to, $subject, $message, $headers) ;
if($sent)
echo "Success!"
}
else
{
echo "Error."
}
?>
答案 0 :(得分:0)
你可以使用这样的东西。
if $type == "work"{
echo '<div style="color:red">Work</div>'; }
if $type == "free"{
echo '<div style="color:green">Free</div>'; }