I have a problem with my script i am trying to format a text area so that on the next page it displays it as it was entered in the textarea.

my css style says this

textarea {
width:450px;
padding:2px;
font: normal 1em Verdana, sans-serif;
border:1px solid #eee;
height:100px;
display:block;
color:#777;

then it is a simple htmll textarea on a php page.

<tr>
<td class="mytransr" id="t_mess">
Message To Client</td>
</tr>
<tr>
<td class="mytransr">
<textarea name="message"></textarea>


<br /></td>


</tr>

the next pae starts and has the line

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

and down the page i have <td><?=$message?>

the problem is in the text area i put

hello how are you?
where are you?
are you there?

on the second page where it displays message it comes out as

hello how are you? where are you? are you there?

how can i make this come out in the same format as it was entered in the initial textarea???

I have been at this 4 hour and hours can anyone ive me a hint please.

thanks

Recommended Answers

All 5 Replies

Try this:

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

nl2br is a PHP function to replace new lines with <BR> tags

wow thanks that worked a treat.

:)

Sorry again I don't supppose there is a way to make urls display as hyperlinks that are sent in a textarea?

i.e www.google.com so it comes out as a hyperlink?

search "BBCode php" and you should have some luck, don't try to re-invent the wheel :p

you can use a free WYSIWYG editor. try tinymce ...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.