A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Insert line break?

  1. #1
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976

    Insert line break?

    I have a from that generates a html page what i have in the form is a few textarea boxes that the user fills in and then clicks submit. But the problem is it doesn't keep the line breaks "<br>" when it returns to the submitted form.

    so on the html output form i have $input = $_POST['input'];
    then the code for a table and <?php echo $input; ?> but instead of remembering the carrage returns it just warps the text.

    How do i achieve this.

    Thanks in Advance

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    You can use nl2br().

    Here's a simple example:
    HTML Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>line breaks</title>
    </head>
    
    <body>
    <?php
    if (isset ($_POST['Submit']))
    {
    $input = $_POST['input'];
    $input = nl2br ($input);
    echo $input;
    }
    else
    {
    ?>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="application/x-www-form-urlencoded" name="form1" target="_self" id="form1">
      <textarea name="input" id="input"></textarea>
      <br />
      <input type="submit" name="Submit" value="Submit" />
    </form>
    <?php
    }
    ?>
    </body>
    </html>
    Remember that there are some security measures that you should follow when receiving user input!

  3. #3
    Who needs pants? hooligan2001's Avatar
    Join Date
    Apr 2001
    Location
    Somewhere
    Posts
    1,976
    Hehe found out how to do it last night. But i want the text to html formatted. It gets outputted to a table in a email. So i had a script that inputs the html code for a image on the net now it doesnt work at all. Does nl2br() stop html properties?

    Thanks for your help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center