简体   繁体   中英

How do I display text in bold in a simple contact form?

I would like to know how to bold face certain text in a contact form. I am sort of new at this. I would like categorize the output of the form. For example:

Contact Information: (in bold) Name:
Email: . . . Event / Trip Details: (in bold) Num of passengers: . . .

So far I have only "Contact information:" and "Event / Trip Details" below. I am not sure what to do to bold face them.

    $formcontent="Contact Information:  \n \nName: $name \n \nEmail: $email 
    \n \nPhone: $phone \n \nCompany / Group Name: $cmpny \n \nStreet Name: 
    $street \n \nCity, State, Zip Code: $city_st_zip \n \nRespond Via:  
    $respond \n \nEvent / Trip Details: \n \nNumber of Passengers:  
    $num_passengers \n \nTrip Type:  $trip_type \n \nNumber of Pickups:  
    $num_pickups \n \nBus Size:  $bus_size \n \nName:  $pickup_name \n 
    \nStreet Name:  $pickup_street_name \n \nCity, State, Zip Code:  
    $pickup_city_st_zip \n \nDepart Date:  $depart_date \n \nDepart Time:  
    $depart_time \n \nName:  $dropoff_name \n \nStreet Name:  
    $dropoff_street_name \n \nCity, State, Zip Code:  $dropoff_city_st_zip 
    \n \nReturn Date:  $dropoff_date \n \nReturn Time:  $dropoff_time \n 
    \nItinerary / Special Instructions / Additional Info:  $spec_instr \n 
    \nAirport Meet & Greet:  $meet_greet \n \nADA Accessible Coach:  $ada \n 
    \nExtra Storage:  $extra \n \nHow did you find us?  $find_us";
    $recipient = "jldouglas58@gmail.com";
    $subject = "Request for a Quote";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    header( 'Location: http://www.distancebrothers.com/quote-
    confirmation.html') ;?>

First of all the email header shoud state that the mail is in HTML format.

$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

Then you format your message in HTML eg:

$formcontent="<html> <body>Contact Information:  \n \nName: <strong>$name </strong>\n \nEmail: $email 
    \n \nPhone: $phone \n \nCompany / Group Name: $cmpny \n \nStreet Name: 
    $street \n \nCity, State, Zip Code: $city_st_zip \n \nRespond Via:  
    $respond \n \nEvent / Trip Details: \n \nNumber of Passengers:  
    $num_passengers \n \nTrip Type:  $trip_type \n \nNumber of Pickups:  
    $num_pickups \n \nBus Size:  $bus_size \n \nName:  $pickup_name \n 
    \nStreet Name:  $pickup_street_name \n \nCity, State, Zip Code:  
    $pickup_city_st_zip \n \nDepart Date:  $depart_date \n \nDepart Time:  
    $depart_time \n \nName:  $dropoff_name \n \nStreet Name:  
    $dropoff_street_name \n \nCity, State, Zip Code:  $dropoff_city_st_zip 
    \n \nReturn Date:  $dropoff_date \n \nReturn Time:  $dropoff_time \n 
    \nItinerary / Special Instructions / Additional Info:  $spec_instr \n 
    \nAirport Meet & Greet:  $meet_greet \n \nADA Accessible Coach:  $ada \n 
    \nExtra Storage:  $extra \n \nHow did you find us?  $find_us </body> </html>";

As I can understand you would like to print that ugly text as a HTML code. Use <strong> tag to make text bold:

<strong>Name:</strong>
<strong> Contact Information:</strong> Name:
<strong> Email: . . . Event / Trip Details:</strong>  Num of passengers: . .

Content must be HTML. You can find free email templates in this website to make it appereance better;

https://colorlib.com/wp/responsive-html-email-templates/

And your content is a variable, it means your variables(like name,email) can not be readable for PHP. You need to parse the content variable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM