Reputation: 36703
I have a <textarea>
in which i save a message which is send to the user who register in my site.
Means i can modify the message from my admin panel.
i use
$message = nl2br($_POST['message']);
This command to store $message in DB everytime whenever i update the message so that it can treat my Enter as a <br>
..
But now suppose if i update the message without making any changes it will add a <br>
to the <br>
(2 line breaks).
I enter in the textarea
Hi
Thanx for contact Us
It will store it as
Hi<br>
Thanx for contacting us<br>
Now if i add a line to it
Hi<br>
Thanx for contacting us<br>
-Team MCXIndiaLive
It will store it as
Hi<br><br>
Thanx for contacting us<br><br>
-Team MCXIndiaLive
How can i stop that???
Upvotes: 0
Views: 980
Reputation: 469
Maybe a better way is storing it 'Clean'. So without the line breaks.
When you display the test you'll add the nl2br, so when you'll edit the text the line breaks won't be added twice.
Upvotes: 1