On my website I have a section with announcements and now I'm working at a tool which will allow moderators to edit or post new announcements. When a moderator posts an announcement he has a form with an input for the title and a textbox for the content of the article. I use nl2br() function (to insert HTML line breaks before all newlines) in the variable which contains the content of the article. So when I insert an article in the database it will look like this:
First row ...<br />Second row.<br /><br />Regards,<br />Moderators team
When a moderator wants to edit an article I have a textbox which containes the article:
<textarea name="body" maxlength="1000" cols="105" rows="10"><?php echo str_replace('<br />', "\n", $content); ?></textarea>
If the moderator click save button (whithout making any modification) the article becomes something like this (the number of
tags doubles):
First row ...<br /><br />Second row.<br /><br /><br /><br />Regards,<br /><br />Moderators team
Can anybody help me to fix this.