ludjer Posted August 31, 2006 Share Posted August 31, 2006 i have a form that takes what ever the user put into it a databasei would like it that when the user puts a new line in (hits Enter)that a br is placed therebit while the guy is typing but when he hits submitthx alot Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/ Share on other sites More sharing options...
redarrow Posted August 31, 2006 Share Posted August 31, 2006 str_replace("bad_letter","</br>",$form_field_name);please read up on str_replace and also eregi_repalce as they are used on php codes daily to modify information form a database and will also intrest you as a learner ok.good luck. Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83500 Share on other sites More sharing options...
Jenk Posted August 31, 2006 Share Posted August 31, 2006 don't use str_replace, use nl2br(). Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83503 Share on other sites More sharing options...
redarrow Posted August 31, 2006 Share Posted August 31, 2006 jenk can you kindly exsplin that syntex of nl2br() please and yes i have read on it but dont use it offthen.can you kindly give an example and exspalin on the code cheers. Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83505 Share on other sites More sharing options...
Jenk Posted August 31, 2006 Share Posted August 31, 2006 [code]<?php$text = "This issome text";echo nl2br($text);?>[/code]Will output:[code]This<br />is<br />some<br />text[/code]:) Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83506 Share on other sites More sharing options...
ludjer Posted August 31, 2006 Author Share Posted August 31, 2006 dude thx alot i will try that now Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83510 Share on other sites More sharing options...
redarrow Posted August 31, 2006 Share Posted August 31, 2006 does that mean when a user press the enter button to make a new line when there adding some text to a form that nl2br makes the <Br/> happen.and thank you so much cheers. Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83511 Share on other sites More sharing options...
Jenk Posted August 31, 2006 Share Posted August 31, 2006 not instantly, but if you pass the data through nl2br on processing, yes it will. Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83512 Share on other sites More sharing options...
redarrow Posted August 31, 2006 Share Posted August 31, 2006 thank youi get it know . Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83513 Share on other sites More sharing options...
ludjer Posted August 31, 2006 Author Share Posted August 31, 2006 ya it works thx alot Quote Link to comment https://forums.phpfreaks.com/topic/19264-x-solved-xusing-auto-new-line-in-a-form-nl2brclub/#findComment-83515 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.