...

View Full Version : Inserting html tags into forms



kjc
06-21-2002, 10:53 AM
I am using PHP and a mysql database. When entering data into a text area in a form and then inserting into the database, I want html tags to automatically be inserted when for paragraphs that have been entered in a text box. Is there anyway of having the <P> inserted into the code. I presume JavaScript is used for this and not PHP.

Also, does anyone know of any free resources for advanced form input(such as this one), where included is features for Bold and Italics etc?

I am greatful for any help in this :thumbsup:

whackaxe
06-21-2002, 12:50 PM
i think it would be safer to use PHP for this. my friend once had this type of problem and used javascript and he ended up having a db full of crap cos the people had saved the page submitting the form and taken out the javascript

JohnKrutsch
06-21-2002, 04:20 PM
PHP has a built in function to do this, nl2br(). I will move this thred to the PHP forum for further discussion.

kjc
06-21-2002, 04:23 PM
Originally posted by JohnKrutsch
PHP has a built in function to do this, nl2br(). I will move this thred to the PHP forum for further discussion.

Thats brilliant. Thank you John

BuZzSaW
06-21-2002, 05:51 PM
You could also do the following


$something = eregi_replace("\r\n","<br>",addslashes($something));

Then you can place that variable when using the set command on your sql query. Use the br tag instead of the paragraph tag, it will double space your paragraphs otherwise. Hope ths helps.

Jeewhizz
06-22-2002, 01:29 PM
That is what nl2br() does :)

ReadMe.txt
06-28-2002, 10:18 PM
if you are going to be using the contents of the field in some form of JS then i recommend using ereg, nl2br() simply appends a <br> tag onto the end of every carriage return



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum