0
I am creating a function so that HTML tags are changed when doing Insert, and then when retrieving.
I’m doing it properly?
CLASS
class handle
{
public static function removeTag($target)
{
$output = preg_replace("#{~#", "<", $target);
$output = preg_replace("#~}#", ">", $target);
$output = preg_replace("#{{q}}#", '"', $target);
return $output;
}
public static function colocaTag($target)
{
$output = preg_replace("<", "#{~#", $target);
$output = preg_replace(">", "#~}#", $target);
$output = preg_replace('"', "#{{q}}#", $target);
return $output;
}
}
When sending to the database:
$comTag = '<p class="important-text">Meu texto com tag </p>';
handle::removeTag($comTag);
Would arrive so in sql
{~p class={{q}}Important-text{{q}}~}My text without tag {~/p~}
Recovering in echo:
$SemTag = '{~p class={{q}}important-text{{q}}~}Meu texto sem tag {~/p~}';
echo handle::colocaTag($SemTag );
<p class="important-text">Meu texto com tag </p>
I’m on the right track?
Maybe this can influence something, so why do you need to do this? There is a limitation/problem in saving HTML in the database?
– Woss
One idea is, instead of using HTML, store a markdown in the bank, then turn the markdown into HTML in the JS frontend
– Costamilam
@Andersoncarloswoss The idea is to increase protection.
– Tiago
Protection against what?
– Woss
@Costamilam markdow, I hadn’t heard of that term.
– Tiago
@Andersoncarloswoss I expressed wrong, it is not protection that the
bind_param
is blocking inserts with tags, so I intend to do something to make it work.– Tiago
@Andersoncarloswoss See https://answall.com/questions/397903/php-bind-param-forbidden
– Tiago
Have you made sure that the problem really is between the
bind_param
and the HTML value?– Woss
You wear it all the time on Stackoverflow (<= This is a markdown)
– Costamilam