Jump to content

Recommended Posts

problem is I have a message page where the user submits a message.

 

it then posts the info to a confirmation page which i am having to post the info to the confirm page using

 

$message      = (nl2br($_POST["message"]));

 

in order to retain the text format then from that page it submits to a submit email page where I use.

 

$message      = ($_POST["message"]);

 

to get the message data and thre email sends fine.

But from this page it also saved the data to the database so it can be resent if need be.

 

Problem is when I am using

 

$message       = $row["message"];

 

the message on thre resend page displays

 

Line 1<br />
Line 2

 

How can I get rid of the <br /> is there any function to strip this when displaying?

Link to comment
https://forums.phpfreaks.com/topic/141537-solved-problem-with-nl2br-function/
Share on other sites

mm ow in the post lines i am not using it anywhere only in the display problem is when i send it in the message.

 

as only $message in the email recieved there are no breaks how do i use this part to make it diplay breaks correctly in what has been sent just using (nl2br($message)) doesn't work?

mm ow in the post lines i am not using it anywhere only in the display problem is when i send it in the message.

 

as only $message in the email recieved there are no breaks how do i use this part to make it diplay breaks correctly in what has been sent just using (nl2br($message)) doesn't work?

 

You either need to send the email using the regular line breaks (no nl2br) or send it with HTML headers for it to display properly with using nl2br.

on thre confirm page it displays perfectly using

<tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'><?=(nl2br($message))?></font></td></tr>

 

then post it to the next page and is gotten by plain old

$message      = ($_POST["message"]);

 

and further down submitted using

 

$to = "$emailcl";
$subject = "$subj";
$MsgHeader = "From: COMPANY NAME. <$email> \n";
$MsgHeader .= "MIME-Version: 1.0\n";
$MsgHeader .= "Content-type: text/html; charset=iso-8859-1";
$MsgBody = "
<html>
<head>
<title>HTML message</title>
</head>
<body>
<tr><td><font style='font-size: 13px' style='font-family: Tahoma, Arial'>$message</font></td></tr>
</body>
</html>";

mail($to, $subject, $MsgBody, $MsgHeader);

 

sends fine but what is revceived looks terrible

 

Blank Email Message Testing Final Run Line 1 Blank Email Message Testing Final Run Line 2 space before this one and line one.

 

should be like this

 

Blank Email Message Testing Final Run Line 1

Blank Email Message Testing Final Run Line 2 space before this one and line one.

 

why is it making it into one line i don't get it??

 

Let me get this right - you have three steps.

 

step 1: user submits message

step 2: message is outputted to screen, where user checks message, then submits it

step 3: message is sent by email, and saved to the database for future reference.

 

Do this:

 

* At the beginning of step 2, save the unedited contents of the message to a session variable.

* Next, run the contents of the variable through the nl2br() function, and output it to the screen (unedited original contents are still contained in the session variable

* At the top of step 3, send the mail using the unedited contents of the session variable, and input that same unedited information into the database (don't use nl2br())

* If in the future you pull the information out of the database to display to the screen, run in through the nl2br() function after pulling it out of the database.

 

I am doing just that I only display on the confirmation page using nl2br() function from there is goes to the submit page

using

 

$message      = ($_POST["message"]);

 

it is passed to the submit page from the confirmation page by

 

<input type="hidden" name="message" value="<?=$message?>" />

 

but when the email is sent using $message it comes out to the user as one long line???

 

 

 

wow I feel so stupid everything was working fine except the email coming out in one line in the email received.

 

so what i did was renamed $message by

 

$message2 = nl2br($message);

 

and in the message i sent i sent $message2 instead of $message why there usually a logical answer that I can't see?

 

problem with using text/plain is on the next email i am building i will have the different problem as that one will contain an html table lol. I got it working now anyway so thanks for the input guys

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.