[SOLVED] printing textarea variable

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • DShadow
    New Member
    • Oct 2006
    • 2

    #1

    [SOLVED] printing textarea variable

    Hi this is my first post and i have a question about php.

    I want to print a variable from textarea and print it in php but when i do all te returns are turned in to spaces. I have used wrap"hard" to include all returns but it doesn't show in php. Or do i have to split the text array with "substr()? Please advise

    this is my code.

    [PHP]
    <html>
    <head>
    <title>Untitl ed Document</title>
    </head>
    <body>
    <?php if ($sendbutton != "send" || !$text) {
    ?>
    <form action="form.ph p" method="post">
    <textarea name="text" cols="50" rows="5" wrap="hard"></textarea><br>
    <input name="sendbutto n" type="submit" value="send">
    </form>
    <?php } else {
    print "text<br>";
    print $text ;
    } ?>
    </body>
    </html>
    [/PHP]
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    There is no value $sendbutton, unless you assign something to it.
    Also, when you POST a form, you must capture the data in the $_POST array when the script is invoked again. I changed your snippet to demonstrate this.
    [php]<?php
    if (isset($_POST['sendbutton'])) {
    echo nl2br(strip_tag s($_POST['text']));
    exit;
    }
    ?>
    <html>
    <head>
    <title>Untitl ed Document</title>
    </head>
    <body>
    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
    <textarea name="text" cols="50" rows="5"></textarea><br>
    <input name="sendbutto n" type="submit" value="send">
    </form>
    </body>
    </html> [/php]
    Ronald :cool:

    Comment

    • DShadow
      New Member
      • Oct 2006
      • 2

      #3
      thanks that is what i ment.

      Comment

      Working...