jeff5656 Posted October 18, 2012 Share Posted October 18, 2012 (edited) When a user enters data into a text box, I want to retain those carriage returns. Therefore I use nl2br. The problem is that when they go to edit the data again, another carriage returns is added. How do I 1. allow carriage returns in a text box and 2. avoid duplicate carriage returns, which the nl2br solution will do? here's the code: <form> <textarea name="medications" value = <?php echo nl2br(stripslashes($rpw['meds']));?></textarea> Edited October 18, 2012 by jeff5656 Quote Link to comment https://forums.phpfreaks.com/topic/269623-nl2br-posting-duplicate-carriage-returns/ Share on other sites More sharing options...
trq Posted October 18, 2012 Share Posted October 18, 2012 nl2br appends <br> tags after newline characters so you do NOT wont to use it when displaying data in a textarea. Why don't you post your actual code? Quote Link to comment https://forums.phpfreaks.com/topic/269623-nl2br-posting-duplicate-carriage-returns/#findComment-1385954 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.