Jump to content

Recommended Posts

How can i do this.

 

Basically, I want the form to die if it has HTML in it. 

 

as people have been submitting things and cancelling out the text area (Vandalizing The Page)

 

Could anyone help me on doing this?

 

-Jamie

 

(I know how to do it if the ONLY text submitted is HTL, but I need it if it has that in alongside other text)

Edited by Jamie_Lyons

Not sure this would work, but my first thought on a simple solution would be to run strip_tags on the form input and compare the length of the resulting string; if it was shorter, then there were tags removed. You could then make the assumption that HTML was submitted and die.

Edited by boompa

Not sure this would work, but my first thought on a simple solution would be to run strip_tags on the form input and compare the length of the resulting string; if it was shorter, then there were tags removed. You could then make the assumption that HTML was submitted and die.

Realised on IRC, didn't even know what strip tags was until i needed it :D

 

Thanks anyway.

 

-Jamie

a very simple way would be to do a preg match to match for greater-than and less-than symbols, which would indicate opening and closing tags.

 

Something very simple like this would be a start:

preg_match("/.*<.*>.*/", $input);

Put that in an if condition, as it will return true if it matches.

 

Hope that helps.

 

Denno

Edited by denno020
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.