Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HELP! How to make text BOLD inside a PHP variable...

Status
Not open for further replies.

000lynx

Programmer
Sep 24, 2007
5
AU
Hey guys, ive got a script that takes info from a form and both submits it to a databse and then mails it also....

The part im focusing on is the MAILING part...Its very hard to read and i want to BOLD the headings...here is a code snippet..

$msg = "New Warranty from Tuff Tonneaus-:\n \n";
$msg.= "Name-: $firstname $lastname\n";
$msg.= "Address-: $address\n";
$msg.= "Suburb-: $suburb\n";
mail($to,$subject.": Warranty",$msg,"From: $from");

That mails, name, adress and suburb just FINE.

Only problem? Id like the headings, "Name-:" "Address-:" and "Suburb-:" to be bolded <b> in HTML...id like to keep this format of code and in php still, so yeah can you help me?

I thought maybe $msg.= '<b>'"Name-:'</b>' $firstname $lastname\n";

OBVIOUSLY i know that wont work, just trying to illustrate WHAT im trying to do exactly :)

Thanks guys! really need a response ASAP

Apreciated!
 
Actually, as long as the mail client receiving the email supports HTML, that's exactly the way to do it.

$msg.="[red]<b>[/red]Name-:[red]</b>[/red] $firstname $lastname\n";

Of course you also need to add the appropriate headers to the email:

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

mail($to,$subject.": Warranty",$msg,"From: $from", [red]$headers[/red]);

For more information, you can see the mail entry in the PHP online manual.




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
well at the moment ive got..

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$msg = "New Warranty from Tuff Tonneaus-:\n \n";
$msg.= "<b>Name-:</b> $firstname $lastname\n";

mail($to,$subject.": Warranty",$msg,"From: $from", $headers);



and that doesnt work?
 
It works for me just fine in Hotmail, and my regular POP3 account through outlook. I see the bold content.




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top