I’m trying to develop an application question forum, where user can submit their answer . But i’ve stuck in one place where,
I’ve a textarea which take a user input , user can type anything they want including html tag, script tag, php tag. and store it in database. After that when i fetches the data i’m showing it inside tag.
<div><?php echo $answere;?></div>
My problem is that when user write <?php ?> tag or <script> tag in answer textarea it’s getting saved properly in database but it showing nothing.
When i fetch and wrap my database saved answer in textarea it’s showing proper result.
Example:
if some one write below text in answer textarea
<?php
// SOME CODE
?>
Result
Inside div it’s showing nothing.
Inside textarea area it’s showing proper result.
Note : I’m not using htmlentities(), html_entity_decode()
Can anyone point me right me direction? Any help would be greatly appreciated.
There is htmlspecialchars() for it.