Textarea没有通过php出现在第二页

时间:2017-12-13 00:57:23

标签: php

当我点击"创建"按钮,.php页面打开,但我想要显示为常规文本,根本不显示。

第一页/ .html

<body>
        <form id="username" action="Post.php" method="post">
            <div class="username">
                <input type="text" form="username" id="username" placeholder="Username" class="username" name="username">
            </div>
        </form>
        <form id="postarea" action="Post.php" method="post">
                <div class="text" align="center">
                    <textarea  name="postarea" form="postarea" class="text" id="postarea" cols="60" rows="15" placeholder="Write your post here"></textarea>
                </div>
            <button class="button" type="sumbit">CREATE</button>
        </form>
    </body>

第二页/ post.php

<body>
        <?php
            echo $_POST["username"]
            echo $_POST["postarea"];
        ?>
    </body>

3 个答案:

答案 0 :(得分:1)

@incredibleHat有理由

按以下方式更改您的代码

第一页:

<body>
<form id="formPostArea" action="post.php" method="post">
  <div class="username">
    <input type="text" form="formPostArea" id="username" placeholder="Username" class="username" name="username">
  </div>
  <div class="text" align="center">
    <textarea name="postarea" form="formPostArea" class="text" id="postarea" cols="60" rows="15"
              placeholder="Write your post here"></textarea>
  </div>
  <input class="button" type="submit" value="CREATE"/>
</form>
</body>

文件post.php

<body>
    <?php
        echo $_POST['username'];
        echo '<br/>';
        echo $_POST['postarea'];
    ?>
</body>

答案 1 :(得分:0)

type="text"标记

中删除textarea

答案 2 :(得分:0)

我尝试了以下内容,它适用于我

PHP

<?php

echo $_POST["username"];
echo $_POST["postarea"];

?>

HTML

<body>
    <form id="username" action="#" method="post">
        <div class="username">
            <input type="text" id="username" placeholder="Username" class="username" name="username">
        </div>

        <div class="text" align="center">
            <textarea name="postarea" class="text" id="postarea" cols="60" rows="15" placeholder="Write your post here"></textarea>
        </div>
        <button class="button" type="sumbit">CREATE</button>
    </form>
</body>