Irksome Posted January 25, 2009 Share Posted January 25, 2009 It's been a while since I've done any PHP, so I'm making a simple guestbook script just to get back into the swing of it. I've managed to get it working just fine except for one thing. When you type some text in the text field that has multiple lines and submit it, it will produce the entry all on one line. For example this entry: Testing 123 Testing 123 Testing 123 Will appear as: Testing 123 Testing 123 Testing 123 I don't even know what the process is called to solve this. I can do it by entering HTML into the text box but that's something I'd rather avoid. Any help on this would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/142350-quick-form-question/ Share on other sites More sharing options...
RichardRotterdam Posted January 25, 2009 Share Posted January 25, 2009 you could use a RTE (rich text editor) javascript Quote Link to comment https://forums.phpfreaks.com/topic/142350-quick-form-question/#findComment-745850 Share on other sites More sharing options...
landavia Posted January 25, 2009 Share Posted January 25, 2009 plz type your code here.. we can't help without view your script btw.. how about use <b>$text = str_replace("\n","<br>",$row[str]);</b> Quote Link to comment https://forums.phpfreaks.com/topic/142350-quick-form-question/#findComment-745855 Share on other sites More sharing options...
revraz Posted January 25, 2009 Share Posted January 25, 2009 nl2br ? Quote Link to comment https://forums.phpfreaks.com/topic/142350-quick-form-question/#findComment-745856 Share on other sites More sharing options...
Irksome Posted January 25, 2009 Author Share Posted January 25, 2009 Oh sorry forgot about the code <?php include("config.php"); if($submit) {//begin of if($submit). $title = mysql_real_escape_string($_POST['title']); $user = mysql_real_escape_string($_POST['user']); $text2 = mysql_real_escape_string($_POST['text2']); //run query $result = mysql_query("INSERT INTO scnews (title, dtime, user, text2) VALUES ('$title',NOW(),'$user','$text2')",$connect); //print success message. echo "<b>Thank you! entry added successfully!<br>"; echo "<meta http-equiv=Refresh content=0;url=index.php>"; }//end of if($submit). else {//begin of else ?> <br> <h3>Add news article</h3> <form method="post" action="<?php echo $PHP_SELF ?>"> Title: <input name="title" size="40" maxlength="255"> <br> Name: <input name="user" size="40" maxlength="255"> <br> Comments: <textarea name="text2" rows="7" cols="30"></textarea> <br> <input type="submit" name="submit" value="Sign Guestbook"> </form> <? }//end of else ?> Quote Link to comment https://forums.phpfreaks.com/topic/142350-quick-form-question/#findComment-745870 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.