I know this question has been asked before but the answers are not the solution to my problem.
When i post a text with this code:
$info=html_entity_decode(mysql_real_escape_string($_POST['info']));
Like :
fdsa
fdsa
fasf
and when i posted this text with antered and spaces it looks like this
<?php echo $info;?>
fdsa
fdsa
fasf
i try this nl2br($info)
but still not working.
What do I need to appear in the text in this way?
fdsa
fdsa
fasf
Replace the by
<br>
, the by
<br>
, then the by
<br>
:
$info = html_entity_decode($_POST['info']);
$info = str_replace('
' , '<br>', $info);
$info = str_replace('
' , '<br>', $info);
$info = str_replace('' , '<br>', $info);
$info = html_entities($info);
echo $info;
You have to make multiples replacements since new lines can be represented differently according to the operating system (See this page for more details)
Finally, sanitize the value with html_entities
before echoing it, preventing client side attacks.
EDIT : Removed the mysql_... function, not needed (the value isn't intended to be inserted in a MySQL database, not now at least).
Also, read Lashus advice bellow and apply it ;)