• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation of user input


Let's say I have a textarea to collect user inputs. Someone turns up and writes a html code (eg. a table of something, or a img tag with src to naked image, a div with 10000px width and height ....) instead of plain text into it. It wouldn't be nice when I print it on my website. How do I avoid it? Is there any library of helper to deal with it?


You could use the php function strip_tags().

You could even just use strip_tags as a validation rule and it will remove it during validation automatically. Put rules that only "prep" data after any rules that return a boolean (those found under Rule Reference).

Lets say I use this way:

$this->form_validation->set_rules('first_name', 'first_name', 'trim|required|strip_tags');

Where do I define allowable_tags? For example allow br, p ..... tags

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.