When typing in textarea this:
<div>
After submit this should be stored as
<div>
in the DB. How can i achieve this?
To encode HTML use htmlentities
and use html_entity_decode
to decode it again.
Encode
<?php
$str = "<div>";
echo htmlentities($str);
?>
Output:
<div>
Decode
echo htmlentities($str, ENT_QUOTES);
Output:
<div>
http://php.net/manual/en/function.htmlentities.php
<?php
$str = "A 'quote' is <b>bold</b>";
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str);
// Outputs: A 'quote' is <b>bold</b>
echo htmlentities($str, ENT_QUOTES);
?>