需要在php中使用粗体标记 [英] Need to use bold tags in php

查看:64
本文介绍了需要在php中使用粗体标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个表单完成它完成和工作正常,当表单提交时,信息通过电子邮件发送到电子邮件ID,但所有内容显示为纯文本,当它提供我想要当表单信息到达电子邮件ID它应该以粗体显示字段名称。

I have this form done it complete and working fine when the form is submitted the information is emailed to an email id but all the content is shown in plain text when it delivers I want that when the form information reaches the email id it it should the field names in bold.

<?php 
$errors = '';
$myemail = 'abc@email.com';//<-----Put Your email address here.


if(
empty ($_POST['fullname']) ||
empty ($_POST['martialstatus']) ||
empty ($_POST['dateofbirth']) ||
empty ($_POST['email']) ||
empty ($_POST['telephone']) ||
empty ($_POST['cell']) ||
empty ($_POST['graduation']) ||
empty ($_POST['yearatt']) ||
empty ($_POST['department']) ||
empty ($_POST['program']) ||
empty ($_POST['permanentaddress']) ||
empty ($_POST['currentemp']) ||
empty ($_POST['designation']) ||
empty ($_POST['selfemp']) ||
empty ($_POST['officeemail']) ||
empty ($_POST['officetele']) ||
empty ($_POST['portfolio']) ||
empty ($_POST['membership']))

{
    $errors .= "\n Error: all fields are required";
}

$fullname = $_POST['fullname'];
$martialstatus = $_POST['martialstatus'];
$dateofbirth = $_POST['dateofbirth'];
$email = $_POST['email'];
$telephone = $_POST['telephone'];
$cell = $_POST['cell'];
$graduation = $_POST['graduation'];
$yearatt = $_POST['yearatt'];
$department = $_POST['department'];
$program = $_POST['program'];
$permanentaddress = $_POST['permanentaddress'];
$currentemp = $_POST['currentemp'];
$designation = $_POST['designation'];
$selfemp = $_POST['selfemp'];
$officeemail = $_POST['officeemail'];
$officetele = $_POST['officetele'];
$portfolio = $_POST['portfolio']; 
$membership = $_POST['membership'];



if( empty($errors))
{
    $to = $myemail; 
    $email_subject = "Membership Information: $fullname";
    $email_body = "You have received a new message. ".
    " Here are the details:\n  Personal Information \n\n 
    Name:                      $fullname \n 
    Martial Status:            $martialstatus \n 
    Date of Birth:             $dateofbirth \n 
    Email:                     $email \n 
    Telephone:                 $telephone \n 
    Cell:                      $cell \n 
    Year of Graduation:        $graduation \n 
    Years Attended:             $yearatt \n
    Department:                $department \n 
    Program Attended:          $program \n 
    Permanent Address:         $permanentaddress \n\n 
    Career Information \n\n 
    Currently Employeed with:  $currentemp \n 
    Designation:               $designation \n 
    Self Employeed:            $selfemp \n 
    Office Email:              $officeemail \n 
    Office Telephone:          $officetele \n 
    Portfolio:                 $portfolio \n\n 
    MemberShip \n\n 
    Type of MemberShip:        $membership \n\n "; 

    $headers = "From: $myemail\n"; 
    $headers .= "Reply-To: $email";

    mail($to,$email_subject,$email_body,$headers);
    //redirect to the 'thank you' page
    header('Location: contact-form-thank-you.html');
} 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html>
<head>
    <title>Contact form handler</title>
</head>

<body>
<!-- This page is displayed only if there is some error -->
<?php
echo nl2br($errors);
?>


</body>
</html>


推荐答案

粗体文本可以使用HTML电子邮件内容类型标题:

Bold text can be done with an HTML email, set the content type header:

$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html;\r\n";

使用< strong>

<strong>Name:</strong>                      $fullname <br />

不要忘记 \\\
在HTML电子邮件中显示新行,您需要使用< br />

Don't forget \n won't show a new line in an HTML email, you'll need to use <br />.

这篇关于需要在php中使用粗体标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆