greetrufus
asked on
No Carriage return from <textarea> tag ??
The following code updates a mysql database and also emails content.
The problem I am having is:
<textarea rows="10" cols="55" name="detail" size="300"></textarea>
is the form tag in my html page.
When the email is send, there are no carriage returns in the message body.
All the text entered in the detail textarea is crammed together.
How do I get the code to recognize the carriage returns?
Here is my code:
<?
$hostname = "localhost";
$username = "username";
$password = "passwd";
$dbName = "consultDB";
/* MySQL table created to store the data */
$userstable = "consult";
/* make connection to database */
MYSQL_CONNECT($hostname,$u sername,$p assword) OR DIE("Unable to connect to database");
@mysql_select_db("$dbName" ) or die("Unable to select database");
/* Insert information into table */
$query = "INSERT INTO $userstable VALUES('','$cDate','$clien tID','$con sultID','$ hours','$d etail')";
$result = MYSQL_QUERY($query);
/* Close the database connection */
MYSQL_CLOSE();
require("class.phpmailer.p hp");
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "localhost"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "mail"; // SMTP username
$mail->Password = "relay"; // SMTP password
$mail->From = "$email";
$mail->FromName = "$consultID";
#$mail->AddAddress("david@ peteshome. com", "Josh Adams");
$mail->AddAddress("email@e mail.com") ; // name is optional
#$mail->AddReplyTo("david@ peteshome. com", "Information");
$mail->WordWrap = 50; // set word wrap to 50 characters
#$mail->AddAttachment("/va r/tmp/file .tar.gz"); // add attachments
#$mail->AddAttachment("/tm p/image.jp g", "new.jpg"); // optional name
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Invoice for $cDate";
$mail->Body = "$clientID<br>$cDate $hours Hours $consultID<BR>$detail";
$mail->AltBody = "";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "<B>Billing has been sent</b>";
?>
The problem I am having is:
<textarea rows="10" cols="55" name="detail" size="300"></textarea>
is the form tag in my html page.
When the email is send, there are no carriage returns in the message body.
All the text entered in the detail textarea is crammed together.
How do I get the code to recognize the carriage returns?
Here is my code:
<?
$hostname = "localhost";
$username = "username";
$password = "passwd";
$dbName = "consultDB";
/* MySQL table created to store the data */
$userstable = "consult";
/* make connection to database */
MYSQL_CONNECT($hostname,$u
@mysql_select_db("$dbName"
/* Insert information into table */
$query = "INSERT INTO $userstable VALUES('','$cDate','$clien
$result = MYSQL_QUERY($query);
/* Close the database connection */
MYSQL_CLOSE();
require("class.phpmailer.p
$mail = new PHPMailer();
$mail->IsSMTP(); // set mailer to use SMTP
$mail->Host = "localhost"; // specify main and backup server
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "mail"; // SMTP username
$mail->Password = "relay"; // SMTP password
$mail->From = "$email";
$mail->FromName = "$consultID";
#$mail->AddAddress("david@
$mail->AddAddress("email@e
#$mail->AddReplyTo("david@
$mail->WordWrap = 50; // set word wrap to 50 characters
#$mail->AddAttachment("/va
#$mail->AddAttachment("/tm
$mail->IsHTML(true); // set email format to HTML
$mail->Subject = "Invoice for $cDate";
$mail->Body = "$clientID<br>$cDate $hours Hours $consultID<BR>$detail";
$mail->AltBody = "";
if(!$mail->Send())
{
echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "<B>Billing has been sent</b>";
?>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
$detail = nl2br($detail);
did it.
Perfect!
Thank you for all your help!!
did it.
Perfect!
Thank you for all your help!!
ASKER