Log in

View Full Version : Textarea - Hyperlinks & Breaks



jnscollier
03-13-2007, 06:52 PM
I'm using a textarea on my site to allow users to post comments. When they enter in a link, it shows up as plain text and not as a hyperlink. Also, when they enter breaks (enters) to space out their comment, it doesn't show that either (it just bunches it all up).

How can I go about getting these things to work? Or is using a textarea a bad choice??

:eek: i just love the eek face.

mburt
03-13-2007, 07:01 PM
You must be using a server-side on the backend to post the comments. Which PHP a simple str_replace, preg_replace would work. The link is a little (actually, alot) more complicated. It's skimming the surface of BBCode.
Here's the answer for the line breaks:

<?php
$new = str_replace("\n","<br>",$originaldata)
//do something with $new (echo for example)
?>
Whereas you would change $originaldata to what was being sent.
It would help more if you described the situation better, or gave the code.

jnscollier
03-14-2007, 05:41 PM
Yeah, I'm using php to display the data gathered from the textarea box.

The breaks now work, so thank you very much for that! As far as displaying links, is there a tutorial or something on this?

Thanks!