Click to See Complete Forum and Search --> : html tag filter


Hinden
02-14-2005, 06:31 AM
Hi all,

I come from a PHP background and am just starting to code ASP pages. My current problem is this:

I have a textarea form in which users can enter info about themselves, in this case a short cv or resume. This info is simply held in a varchar field in a table. Some of the more crafty users have been entering html code in the form to play with their fonts, creating tables etc which are stored in the database. What is the best way to filter html code out of the inputted user form data?

Many thanks in advance...

buntine
02-14-2005, 07:50 AM
Replace < and > with their ascii equivelants.

strContent = Replace(strContent, "<", "&lt;")
strContent = Replace(strContent, ">", "&gt;")

strContent refers to a variable that holds the value of the textarea. This should actually just print the HTML to the page.

There is also a handy funtion available at 4guysfromrolla.com that will solve your problem. See it here: http://www.4guysfromrolla.com/webtech/073000-1.shtml

Regards.

Hinden
02-14-2005, 08:33 AM
That link is exactly what I was after, thanks!