Jump to content

[SOLVED] need some help with line breaks..


CSmith1128

Recommended Posts

ok.. heres what I have... i am making a message system where the users can send eachother messages.

I have a reply feature so they can reply to messages received.

The problem I am having deals with line breaks.

 

- I store each message in a text file.

- When the user clicks reply, it takes the text from the text file and store it into a text area form box.

- To insert the line breaks I use \n. It shows up fine in the text area.

- Now when I send it to the script, I use $_REQUEST['message']; to retreive it.

- To debug it, I have the text displayed on the page so I know what it looks like before it is stored.

- However, it does not show the line breaks.

 

- I have tried changing the line breaks to html using <br>, however, when it is displayed in the text area, it shows <br> instead of the actual line break. So if i want to display the previous message, it shows <br> instead of the line.

 

- Does anyone know away around this so I can show the line breaks in both the text area and text file without having the user see <br>?

- Also, when the user inserts a new line in the text area when the are typing a new message it does not show up as a new line.. is there a fix for this too?

 

Thanks

 

Chris

Link to comment
https://forums.phpfreaks.com/topic/51246-solved-need-some-help-with-line-breaks/
Share on other sites

yeaa that works, however, in the text area it shows "br \".. I just want it to show lines in the text area instead of the actual html... this is what I am trying to put into the text area...

 

$doubleLine = "-----------------------------------\n-----------------------------------";

$line = "-----------------------------------";

$newMessageValue = "\n\n\n\n\n" . $doubleLine . "\nMessage From: " . $firstname . " " . $lastname . "\n" . $tmonth . " " . $tday . ", " . $tyear . " at " .  $thour . "\n" . $line . "\n" . nl2br($oldMessage);

 

 

with that, everything works fine and when it sends it to the script, it shows up how I want it.. so I can change the lines to the following, but then it shows up with the br \ in the text area, which i am trying to avoid if possible..

 

$doubleLine = "-----------------------------------br /-----------------------------------";

$line = "-----------------------------------";

$newMessageValue = " br / br / br / br / br /" . $doubleLine . "br /Message From: " . $firstname . " " . $lastname . "br /" . $tmonth . " " . $tday . ", " . $tyear . " at " .  $thour . "br /" . $line . "br /" . nl2br($oldMessage);

 

is there away around that?  if not i can live with it showing the br / in the text area..

 

Note:  in the code above it needs the  < and > around br \ , i just left it out because it doesnt show up when the topic is submitted, and i dont know a way around it.

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.