I need help in figuring out where to put in code to make certain fields bold in the email produced by a form. I want the "Library Name", "Work Requested", "Terminal Name", etc. to be bold and the output inputted by the form to be normal font so it is easier to read in the email. Where can I put <b> tags into the php to make this happen?? I'm new to this php stuff so any help would be greatly appreciated!!:roll:
$body = "";
$body .= "Library Name: " . stripData($_POST['Library']) . "\n";
$body .= "Work Requested: " . stripData($_POST['Work']) . "\n";
$body .= "Terminal Name (If known): " . stripData($_POST['Terminal']) . "\n";
$body .= "New Port: " . stripData($_POST['New']) . "\n";
$body .= "Type of port: " . stripData($_POST['If']) . "\n";
$body .= "Date PC in place: " . stripData($_POST['Date']) . "\n";
$body .= "Cabling completed and Patch cables installed: " . stripData($_POST['Cable']) . "\n";
$body .= "If No, Date Cabling will be completed: " . stripData($_POST['IfNo']) . "\n";
$body .= "Requested Work Completion Date: " . stripData($_POST['Completion']) . "\n";
$body .= "Special Hours: " . stripData($_POST['Special']) . "\n";
$body .= "Agreement answer: " . stripData($_POST['Yes']) . "\n";
mail("asavoie@cwmars.org", "Online Work Request", $body, "From: \"" . stripData($_POST['name']) . "\" <" . stripslashes($_POST['email']) . ">");
$mailed = "Your request has been emailed. Thank you. You will receive a call from C/W MARS to authenticate this form request!!";
}
}
?>
<html>
<head>
<title>Form Mailer</title>
<META HTTP-EQUIV="PRAGMA" CONTENT="NOCACHE">
<style type="text/css">
.TitleTxt { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 18px; font-style: normal; font-weight: bold; font-variant: normal; color: #339999}
.NormalTxt { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; font-style: normal; font-weight: normal; font-variant: normal; color: #339999}
.ErrorTxt { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; font-weight: normal; font-variant: normal; color: #FF0000}
</style>
</head>
<body bgcolor="white">
<p class="TitleTxt" align="center">Online Work Request Form</p>
<p class="NormalTxt" align="center"><?php echo $mailed; ?></p>
<?php
if ($error || !isset($_POST['submit'])) { ?>
<p class="NormalTxt" align="center">Please complete and submit the following form.</p>
<p class="ErrorTxt" align="center"><?php echo $error; ?></p>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
<table align="center">
<tr><td align="right" valign="top"><p class="NormalTxt">Name: </p></td><td><input name="name" type="text" size="20" maxlength="70" value="<?php echo htmlspecialchars($_POST['name']) ?>"></td></tr>
<tr><td align="right" valign="top"><p class="NormalTxt">Email: </p></td><td><input name="email" type="text" size="20" maxlength="70" value="<?php echo htmlspecialchars($_POST['email']) ?>"></td></tr>
<tr><td align="right" valign="top"><p class="NormalTxt">Library Name/Town: </p></td><td><input name="Library" type="text" value="<?php echo htmlspecialchars($_POST['Library']) ?>" size="30" maxlength="100"></td></tr>
<tr><td align="right" valign="top"><p class="NormalTxt">Work Requested: </p></td><td><textarea name="Work" cols="30" rows="5"><?php echo htmlspecialchars($_POST['Work']) ?></textarea></td></tr>
<tr><td align="right" valign="top"><p class="NormalTxt">Terminal Name, if known: (i.e. NCW01,P02CW): </p></td><td><input name="Terminal" type="text" value="<?php echo htmlspecialchars($_POST['Terminal']) ?>" size="30" maxlength="100"></td></tr>
<tr><td align="right" valign="top"><p class="NormalTxt">New Port: </p></td><td>
<input name="New" type="radio" value="Yes" <?php if ($_POST['New'] == "Yes") { echo "checked=\"true\""; } ?>><span class="NormalTxt">Yes</span><br>
<input name="New" type="radio" value=" No" <?php if ($_POST['New'] == " No") { echo "checked=\"true\""; } ?>><span class="NormalTxt"> No</span><br></td></tr>
<tr><td align="right" valign="top"><p class="NormalTxt">Type of port: </p></td><td>
<input name="If" type="radio" value="STAFF" <?php if ($_POST['If'] == "STAFF") { echo "checked=\"true\""; } ?>><span class="NormalTxt">STAFF</span><br>
<input name="If" type="radio" value="PAC" <?php if ($_POST['If'] == "PAC") { echo "checked=\"true\""; } ?>><span class="NormalTxt">PAC</span><br>
<input name="If" type="radio" value="TRAINING" <?php if ($_POST['If'] == "TRAINING") { echo "checked=\"true\""; } ?>><span class="NormalTxt">TRAINING</span><br>
<input name="If" type="radio" value="INTERNET ONLY" <?php if ($_POST['If'] == "INTERNET ONLY") { echo "checked=\"true\""; } ?>><span class="NormalTxt">INTERNET ONLY</span><br>
<input name="If" type="radio" value="CONTENDING" <?php if ($_POST['If'] == "CONTENDING") { echo "checked=\"true\""; } ?>><span class="NormalTxt">CONTENDING</span><br>
<input name="If" type="radio" value="VARIOUS" <?php if ($_POST['If'] == "VARIOUS") { echo "checked=\"true\""; } ?>><span class="NormalTxt">VARIOUS</span><br></td></tr>
<tr><td align="right" valign="top"><p class="NormalTxt">Date PC will be in place: </p></td><td><input name="Date" type="text" value="<?php echo htmlspecialchars($_POST['Date']) ?>" size="30" maxlength="100"></td></tr><br>
<tr><td align="right" valign="top"><p class="NormalTxt">Has cabling been completed and patch cables installed for PC: </p></td><td>
<input name="Cable" type="radio" value="Yes" <?php if ($_POST['Cable'] == "Yes") { echo "checked=\"true\""; } ?>><span class="NormalTxt">Yes</span><br>
<input name="Cable" type="radio" value=" No" <?php if ($_POST['Cable'] == " No") { echo "checked=\"true\""; } ?>><span class="NormalTxt"> No</span><br></td></tr>
<tr><td align="right" valign="top"><p class="NormalTxt">If No, when will it be completed: </p></td><td><input name="IfNo" type="text" value="<?php echo htmlspecialchars($_POST['IfNo']) ?>" size="30" maxlength="100"></td></tr><br>
<tr><td align="right" valign="top"><p class="NormalTxt">Requested Completion Date: </p></td><td><input name="Completion" type="text" value="<?php echo htmlspecialchars($_POST['Completion']) ?>" size="30" maxlength="100"></td></tr><br>
<tr><td align="right" valign="top"><p class="NormalTxt">Special Library Hours: </p></td><td><textarea name="Special" cols="30" rows="5"><?php echo htmlspecialchars($_POST['Special']) ?></textarea></td></tr><br>
<tr><td colspan="2" align="center"><input type="Submit" name="submit" value="Submit"></td></tr>
<p><b>I understand that any additional work requested at the time of this visit and not listed on this form may require a separate visit due to scheduling. Request for work not listed on this form must be approved by the Systems and Networking Manager.
Please also note that all cabling is the responsibility of the library, this also includes patch cables for the PC.<br></b>
</p>
<input name="Yes" type="radio" value="Yes, I Understand" <?php if ($_POST['Yes'] == "Yes") { echo "checked=\"true\""; } ?>><span class="NormalTxt"><font color="red">Yes, I Understand</font></span><br>
</td></tr>
</table>
PHP font format in email output
Moderator: General Moderators
seems to be $body you have to alter.
And you have to make it a html-mail
take a look at "Example 4. Sending complex email." of the mail()-manual
the 'trick' is in the headers sent.
You already have the From-field included but you also need at least
"MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"
And you have to make it a html-mail
take a look at "Example 4. Sending complex email." of the mail()-manual
the 'trick' is in the headers sent.
You already have the From-field included but you also need at least
"MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n"
PHP font format in email output
Excuse me for being such a newbie but where would this, "MIME-Version: 1.0\r\nContent-type: text/html; charset=iso-8859-1\r\n", be added?? The items I want bold are part of the body of the email and not headers to be in the header of the email?? If that makes sense? So why would I need to add a header command? 
email (smtp) is a very old protocol/format. It didn't know anything except plain text when it was 'invented'. Then they added mime to mail, making it possible to devide mails in several parts. For each part you can i.e. set the content type.
With "MIME-Version: 1.0\r\n" in the header you mark the mail as mime-mail - but it is still possible to view in an old plain-text-mail-viewer (may look strange).
the following "Content-type: text/html;" marks two things. 1st: there is only one part, 2nd: it should be handled as HTML (parsing <b>text</b> as bold)
if you take a look at your script
p.s.:to make it a little bit easier for you (but without providing you the whole script - something to learn anyway) look at your script changed this way
With "MIME-Version: 1.0\r\n" in the header you mark the mail as mime-mail - but it is still possible to view in an old plain-text-mail-viewer (may look strange).
the following "Content-type: text/html;" marks two things. 1st: there is only one part, 2nd: it should be handled as HTML (parsing <b>text</b> as bold)
if you take a look at your script
and at the examplemail("asavoie@cwmars.org", "Online Work Request", $body, "From: \"" . stripData($_POST['name']) . "\" <" . stripslashes($_POST['email']) . ">");
I'm sure you will find the place where you have to put the header-lines$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: Birthday Reminder <birthday@example.com>\r\n";
$headers .= "Cc: birthdayarchive@example.com\r\n";
$headers .= "Bcc: birthdaycheck@example.com\r\n";
mail($to, $subject, $message, $headers);
p.s.:to make it a little bit easier for you (but without providing you the whole script - something to learn anyway) look at your script changed this way
Code: Select all
$to = "asavoie@cwmars.org";
$subject = "Online Work Request";
$message = $body;
$header = "From: "" . stripData($_POSTї'name']) . "" <" . stripslashes($_POSTї'email']) . ">";
mail($to, $subject, $message, $header);