Validation of user input - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Validation of user input (/showthread.php?tid=52807) |
Validation of user input - El Forum - 06-27-2012 [eluser]veledrom[/eluser] Hi, 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? Thanks Validation of user input - El Forum - 06-27-2012 [eluser]BigBad[/eluser] You could use the php function strip_tags(). Validation of user input - El Forum - 06-27-2012 [eluser]CroNiX[/eluser] 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). Validation of user input - El Forum - 06-28-2012 [eluser]veledrom[/eluser] Lets say I use this way: Code: $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 |