Jump to content

Recommended Posts

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";
}

?>

Link to comment
https://forums.phpfreaks.com/topic/63248-solved-form-issue/
Share on other sites

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');

Link to comment
https://forums.phpfreaks.com/topic/63248-solved-form-issue/#findComment-315287
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.