Reputation: 3402
I have a joomla component and trying to filter HTML content from the users input.
$input = $app->input->post->getRaw('question');
This will getting me the RAW html.
How can I check (The joomla way or custom php function) is it safe before saving into my database?
Thanks!
Upvotes: 1
Views: 958
Reputation:
You can convert the input to a string, striping all HTML tags/attributes, this way:
$jinput = JFactory::getApplication()->input;
$input = $jinput->get('question', 'default_value', 'html');
Official Documentation: Retrieving request data using JInput
Upvotes: 1
Reputation: 9615
Joomla has an automatic function for that, please check System -> Global Configuration -> Text Filters
and set the appropriate filtering for your user group.
If you want to do that with php, you could use strip_tags() function. Your result would be like:
$input = strip_tags($app->input->post->getRaw('question'));
Good Luck!
Upvotes: 1