[TYPO3-project-formidable] Stripping HTML tags from user input before DB insertion

Jerome Schneider typo3dev at ameos.com
Wed Feb 25 10:41:22 CET 2009


Hi Leopold,
When I have to achieve this kind of processing, I use the 
beforeInsertion too :)

There's no other way to do so for the moment.

What feature would you have expected ?

Regards,
Jerome Schneider

Leopold Mayr a écrit :
> Hi list!
> 
> I have created a user database where users can edit their data 
> themselves. I wanted to strip any html tags from the user's input before 
> it is stored in the DB.
> 
> Therefore I wrote a beforeinsertion process (code below) to strip the 
> tags and it works (as far as I can tell right now).
> 
> I'm just wondering if there is another possibility of doing this? Am I 
> missing anything?
> 
> Thanks in advance,
> 
> Leo
> 
> 
> Here goes the code:
> 
> <datahandler:DB>
>     <tablename>fe_users</tablename>
>     <keyname>uid</keyname>
>     <process>
>         <beforeinsertion>
>             <userobj>
>                 <php><![CDATA[
>                     //get form values
>                     $aData = array_pop(func_get_args());
>                    
>                     //create anonymous function for stripping tags
>                     $sanitize = create_function ('&$value, $key', 
> '$value = strip_tags ($value);');
>                    
>                     //apply anonymous strip tags function to every form 
> field
>                     array_walk ($aData, $sanitize);
>                    
>                     return $aData;
>                 ]]></php>
>             </userobj>
>         </beforeinsertion>
>     </process>
> </datahandler:DB>
> 
> 


More information about the TYPO3-project-formidable mailing list