Forum Moderators: coopster

Message Too Old, No Replies

Detect Tags Function

For use with form validation

         

neophyte

11:07 pm on Sep 2, 2007 (gmt 0)

10+ Year Member



Hello All -

I'm interested in beefing up my form validation routine to check for HTML tag (and ideally SQL-type) input.

If the validation routine finds tags in the posted input, it will echo back the input with a warning that no code input is allowed. I've looked around the PHP manual and found the strip_tags() function (as well as htmlentities and htmlspecialcharacters), but all that I want is a function that will return TRUE/FALSE if html tags/characters are found.

I could write my own reg-exp to do this, but there would be quite a bit of exceptions to try and trap for.

Is there a pre-rolled PHP function that will do this?

Neophyte

cameraman

10:09 am on Sep 3, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You could compare the original input to the result of striptags() - if they're the same, there must not have been any tags in the input.