jasonc Posted June 3, 2011 Share Posted June 3, 2011 If a field is missed out when filling out a ofrm on my page they are taken back and told that they missed one out, the data they had already typed in is shown again. but all the returns show as \r\n how do I have it so the returns show as they were typed and not as the \r\n. EDIT: also how to i get the £ to show in my page as a £ and not as the diamond with a question mark. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 you can convert all returns with: str_replace("\n\r","whatever_you_want",$string); Quote Link to comment Share on other sites More sharing options...
jasonc Posted June 3, 2011 Author Share Posted June 3, 2011 ah yes i have see that before, but how do i get the carriage return to be put back as they had originally typed in like on this forum if I put returns here they show again if i was to forget to fill out the title. Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 when they type into an html text area the returns are sent as \n (most probably), but if you want to display them in html you have to convert them to <br /> echo str_replace("\n","<br />",$string); hope this helps Quote Link to comment Share on other sites More sharing options...
Kieran Menor Posted June 3, 2011 Share Posted June 3, 2011 Could we see the code that processes the form? Textareas are supposed to show linebreaks correctly, so what you are describing sounds rather weird. Regarding the £ sign, it seems to be a character encoding problem. What encoding are you using for your page? Quote Link to comment Share on other sites More sharing options...
jasonc Posted June 3, 2011 Author Share Posted June 3, 2011 strange i get them displayed as \r\n Quote Link to comment Share on other sites More sharing options...
WebStyles Posted June 3, 2011 Share Posted June 3, 2011 you shouldn't even be seeing them. can you post the code please? Quote Link to comment Share on other sites More sharing options...
jasonc Posted June 3, 2011 Author Share Posted June 3, 2011 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted June 3, 2011 Share Posted June 3, 2011 when they type into an html text area the returns are sent as \n (most probably), but if you want to display them in html you have to convert them to <br /> echo str_replace("\n","<br />",$string); There's a built-in function for that: nl2br Ken Quote Link to comment 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.