Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2005
    Location
    Melbourne, Australia
    Posts
    7,554
    Tokens
    0

    Latest Awards:

    Default PHP display text in textarea

    PHP Code:
    <?php
    include("connect.php");
    if(isset(
    $_SESSION['username'])){

    if(
    $_POST[preview]){
        
    $title $_POST['title'];
        
    $textarea $_POST['textarea'];

        echo(
    "<p align=\"center\"> <b>This is just a preview</b> </p>");
        echo(
    "<form method=\"post\">
        <b>Title</b>: <input name=\"title\" type=\"text\" value=\"
    $title\" maxlength=\"75\"><br />
        <b>Author</b>: 
    $username<br />
        <b>News</b>: <textarea name=\"textarea\" cols=\"40\" value=\"
    $textarea\" rows=\"10\"></textarea><br />
        <input type=\"submit\" name=\"preview\" value=\"Preview post\">
        <input type=\"submit\" name=\"addnews\" value=\"Add news article\">
        </form>"
    );

    } elseif(
    $_POST['addnews']){

        
    $title mysql_real_escape_string($_POST['title']);
        
    $news mysql_real_escape_string($_POST['news']);
        
    $title stripslashes($title);
        
    $news stripslashes($news);
        
    $datetime date("d/m/Y H:i:s");

        
    $query "INSERT INTO news (title, author, news, shortnews, datetime) VALUES ('" $title "', '" $author "', '" $news "', '" $news "', NOW())";

        
    mysql_query($query) or die(mysql_error());

        echo(
    "News was posted succsesfully. ");

    } else {
        
        echo(
    "<form method=\"post\">
            <b>Title</b>: <input name=\"title\" type=\"text\" maxlength=\"75\"><br />
            <b>Author</b>: 
    $username<br />
            <b>News</b>: <textarea name=\"textarea\" cols=\"40\" value=\"
    $textarea\" rows=\"10\"></textarea><br />
            <input type=\"submit\" name=\"preview\" value=\"Preview post\">
            <input type=\"submit\" name=\"addnews\" value=\"Add news article\">
            </form>"
    );

    }
    } else {
        echo(
    "You have to be logged in to view this page.");
    }
    ?>
    Why doesn't the above code show the text in the textbox?
    The input text (title) works but the textarea (which is the news article) doesn't at all .

    +rep

  2. #2

    Default

    Because textarea doesn't work how you're using it, like inputs value="", it works like <textarea></textarea>, and what ever is between it, will be in the text area.

  3. #3
    Join Date
    Jun 2008
    Location
    Manchester
    Posts
    766
    Tokens
    0

    Default

    As Iszak said, replace:
    Code:
        <b>News</b>: <textarea name=\"textarea\" cols=\"40\" value=\"$textarea\" rows=\"10\"></textarea><br />
    with:
    Code:
        <b>News</b>: <textarea name=\"textarea\" cols=\"40\" rows=\"10\">$textarea</textarea><br />

Posting Permissions

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