cha0sriderx Posted August 3, 2007 Share Posted August 3, 2007 i was wondering when make a form with a text area how do u make it show the breaks? like if u have this is a textarea: abc def normally is shows up as: abc def how do u make it show up how it is in the textarea? this is what i have: contact.php <form action="send.php?form=contact" method="post"> <table class=form align=center> <tr> <td align=right valign=bottom> Name: </td> <td> <input type="text" name="name" size="35"> </td> </tr> <tr> <td align=right valign=bottom> Email: </td> <td> <input type="text" name="email" size="35"> </td> </tr> <tr> <td align=right valign=top> Message: </td> <td> <textarea name="comment" rows="8" cols="35"></textarea> </td> </tr> <tr> <td align=center> </td> <td align=right> <input type="submit" value="Send Form"> <input type="reset" value="Reset"> </td> </tr> </table> </form> send.php <? $form = $_GET['form']; if ($form == contact) { $n = $_POST['name']; $e = $_POST['email']; $c = $_POST['comment']; if ((empty($n)) || (empty($e)) || (empty($c))) { echo "<center>Please fill out the form completely.<br><a href='contact.php'>back</a></center>"; exit(); } echo "$n ($e)<br>$c"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/63248-solved-form-issue/ Share on other sites More sharing options...
deadimp Posted August 3, 2007 Share Posted August 3, 2007 You'll need to format your normal text to HTML, either by using some PHP function or for simply handling line breaks, replace the characters ("\n" (LF on Unix), "\r\n" (CR+LF on Windows)) with the HTML break tag "<br>". Quote Link to comment https://forums.phpfreaks.com/topic/63248-solved-form-issue/#findComment-315247 Share on other sites More sharing options...
Fadion Posted August 4, 2007 Share Posted August 4, 2007 Basically, HTML uses <br /> while the textarea uses \n. When for ex u enter some text from a textarea in a database, retrieving that data from the db u would have smth like 'text\ntext\ntext'. To convert all the newlines in html brakes u can use the nl2br function. Pretty easy: echo nl2br('this is some\ntext'); Quote Link to comment https://forums.phpfreaks.com/topic/63248-solved-form-issue/#findComment-315287 Share on other sites More sharing options...
cha0sriderx Posted August 4, 2007 Author Share Posted August 4, 2007 thanks a lot it works really well. Quote Link to comment https://forums.phpfreaks.com/topic/63248-solved-form-issue/#findComment-315719 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.