dongruidian3064 2014-08-26 00:17
浏览 58
已采纳

张贴到自己textarea空白

I've been looking through the site and going over pointers on similar problems but none have seemed to work for me. I'm a wee bit stuck, hoping someone can point out my stupidity.

I created a basic form to test as my main site was giving me problems. There is no error checking or filtering for malicious code, it's just a test to figure out why it won't work. I can't retrieve any data from a textarea. All other types work, text, number, etc... all fine.

Here is my basic form, can anyone see the error of my ways?

<?php
require_once('header.php');
if(isset($_POST['submit'])) 
{ 
    echo "<br>single line comment: " .$_POST['singlelinecomment'];

    if (!isset($_POST['comments']))
    {
        echo "<br>nothing in textarea data, move along, move along";
    }
    else
    {
        $comments = $_POST['comments'];
        echo "<br>comments: ". $comments;
    }
}
?>
<form name="conversation-form" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
    <table>
        <tr>
            <td>
                <input type='text' name="singlelinecomment">
            </td>
        </tr>
        <tr>
            <td>
                <textarea rows="20" cols="50" form="conversation-form" name="comments"></textarea>
            </td>
        </tr>
        <tr>
            <td>
                <input type="submit" name="submit" value="Submit" /><br>
            </td>
        </tr>
    </table>
</form>
  • 写回答

1条回答 默认 最新

  • duanlian1960 2014-08-26 00:24
    关注

    form="conversation-form" remove it from textarea, it's the main cause.

    Plus, you don't need this name="conversation-form" in <form>, unless you want to use it for CSS purposes, then use id="conversation-form" or class="conversation-form"

    <textarea rows="20" cols="50" form="conversation-form" name="comments"></textarea>
                                  ^^^^^^^^^^^^^^^^^^^^^^^^ remove it
    

    <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
        <table>
            <tr>
                <td>
                    <input type='text' name="singlelinecomment">
                </td>
            </tr>
            <tr>
                <td>
                    <textarea rows="20" cols="50" name="comments"></textarea>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" name="submit" value="Submit" /><br>
                </td>
            </tr>
        </table>
    </form>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错