Results 1 to 7 of 7

Thread: Passing Textarea data with multilines to another page

  1. #1
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Passing Textarea data with multilines to another page

    Hi guys,

    I'm new to php. And i think my problem is really simple. But I could not find a solution for it. Like I said, I'm a php newbie.
    So my problem is dealing with data with multilines. Supposedly, the field value will be passed to another page through a variable. If it's a single line, then no problem. But if there are line breaks, it returns an error: Warning: Header may not contain more than a single header, new line detected

    Please help, thanks.

  2. #2
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Please post your php script so we can look at it and get out any errors.
    This may be very easy to fix. Please also provide a link (if it is online) to see if we get the same problem.
    Thanks,
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  3. #3
    Join Date
    Apr 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry, but i am not allowed to post the codes but below is the key areas that i think causing problems...

    This is where the value of the text area is being processed
    PHP Code:
    $F8 POST_VARS["field8"];
    header("Location: go.php?field8=$F8"); 
    The text area...
    PHP Code:
    <textarea name="field8" cols="38" wrap="physical" style="width: 85%; height: 50px;">
    </
    textarea

  4. #4
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    This is happening because you can only have one line in though GET. If you are using this script on the same page as your form, use POST:
    Code:
    <form action="go.php" method="post">
    ...
    then on go.php
    Code:
    <?
    $feild8 = $_POST['feild8'];
    //with "feild8"(inside $_POST) is the name of the textarea
    ?>
    You could also use $_SESSION, but thats somting a little to much for what you are tring to do.
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  5. #5
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    Did you try my example?
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

  6. #6
    Join Date
    Jul 2006
    Location
    just north of Boston, MA
    Posts
    1,806
    Thanks
    13
    Thanked 72 Times in 72 Posts

    Default

    submitting form information should not be done with the GET method as fileserverdirect states, and to keep the newlines entered into a textarea input box, use the nl2br() function for php

  7. #7
    Join Date
    Nov 2006
    Location
    Northeast USA
    Posts
    408
    Thanks
    8
    Thanked 30 Times in 28 Posts

    Default

    boogyman:
    nl2br(); replaces new lines with HTML tag <br>. If there is any database interaction, form mailing, etc., the varable would look like this: $field8 = "Hello<br>this is a new line<br>Hello again, another line here";
    If s/he was echoing out this variable, then it could be O.K., but if it's used in a script, it will mess up every thing. S/He could however use eregi_replace();.
    rhardo:
    It is still safer to use the method "POST", and you would not need any of this.
    ------------------
    YAY! 200 POSTS! WOOT!
    (only 150 more to go )
    Last edited by fileserverdirect; 04-17-2008 at 10:39 PM. Reason: 200th post!
    -Ben -- THE DYNAMIC DRIVERS
    My Links: My DD Profile||My Youtube Video Tutorials||DD Helping Coders||DD Coders In Training
    I told my client to press F5, the client pressed F, then 5, *facepalm*

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
  •