Welcome Guest, Not a member yet? Register   Sign In
Validation of user input
#1

[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
#2

[eluser]BigBad[/eluser]
You could use the php function strip_tags().
#3

[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).
#4

[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




Theme © iAndrew 2016 - Forum software by © MyBB