Results 1 to 6 of 6

Thread: user hits "enter" on form, form display on next page newline?

  1. #1
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default user hits "enter" on form, form display on next page newline?

    If I make a textarea in a form, and the user is filling it out and uses the carriage return to go to the next line, when they submit the form the carriage return is replaced with a single space.

    Is there something I can put either on the form coding or on the second page that will make the carriage returns show as a new line on the rendered form?

    It is in re: this post

    Thanks guys.
    Last edited by BLiZZaRD; 12-13-2007 at 05:25 PM.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Look in nl2br.

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Or better, provide a markup language like Markdown so that the user can format it appropriately.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I already tried nl2br, and it didn't work for me. I probably did it wrong, but I got parse errors on the 2nd page.

    As is obvious, this isn't for me, I don't have a need for it right now other than finishing that script, but it may come in handy someday.

    If I have this on the first page of the form:

    <textarea name=Whatever rows=12 cols=50></textarea>

    and I have this on the second:

    <?php echo $_POST["Whatever"]; ?>

    where would I use the nl2br()? I have tried in the declaration of "whatever" I have tried making each $_POST... a string with it in header declaration, on the first page, on the second page...

    Nothing worked.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You would use it like so:

    Code:
    <?php echo nl2br($_POST['Whatever']); ?>
    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    I tried that and got header errors.. maybe I didn't completely remove something. I will try it again...

    Thanks TS

    Edit:
    That was it.. I had the closing paren in the wrong side of the semi-colon. DUH!

    Got it right, updated the script. All is well. Thanks again.
    Last edited by BLiZZaRD; 12-15-2007 at 08:24 PM.
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

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