sanitizing field inputs

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
madsamurai
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Oct 02, 2007 6:13 pm

sanitizing field inputs

Post by madsamurai » Tue Feb 26, 2008 10:15 pm

I was wondering about the usage of JRequest::clean() vs JRequest::cleanVar()... what is the difference, and when to use which?

I want to sanitize my form input data before I save it to the database, so in my save function would I use something like:

Code: Select all

$data = JRequest::cleanVar( 'post' );
or do I need to include the get(), as in:

Code: Select all

$data = JRequest::cleanVar( JRequest::get( 'post' ) );
or would I use clean() where I've used cleanVar() in these examples? Unfortunately the wiki isn't very helpful for these functions yet. Thanks in advance!

User avatar
madsamurai
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Oct 02, 2007 6:13 pm

Re: sanitizing field inputs

Post by madsamurai » Thu Feb 28, 2008 3:22 pm

OK... maybe I'm asking this the wrong way.

What is the proper way to clean a post array from form inputs? maybe JFilter is what I'm looking for? I keep trying stuff, and just keep getting errors.

User avatar
Rogue4ngel
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 199
Joined: Sun Nov 26, 2006 10:46 pm
Location: New York

Re: sanitizing field inputs

Post by Rogue4ngel » Thu Feb 28, 2008 10:11 pm

What version of Joomla are you working with??
If you're not a part of the solution, you're a part of the problem.

User avatar
madsamurai
Joomla! Apprentice
Joomla! Apprentice
Posts: 20
Joined: Tue Oct 02, 2007 6:13 pm

Re: sanitizing field inputs

Post by madsamurai » Thu Feb 28, 2008 10:44 pm

Rogue4ngel wrote:What version of Joomla are you working with??
working in J1.5.1


Post Reply