不能在请求中获取TextArea值,总是空的

Can't get TextArea value in the Request, always empty

本文关键字:TextArea 请求 获取 不能      更新时间:2023-09-26

echo的结果总是:"课程描述值为……谢谢"使用Course_Desc

的空值
 <?
     if (isset($_REQUEST["saveEdites"])) {
        $id = $_REQUEST['ProtocolID'];
        $Course_Desc = $_REQUEST['Course_Descr'];
        $Course_Desc = trim($Course_Desc);
        $Course_Desc = stripslashes($Course_Desc);
        $Course_Desc = htmlspecialchars($Course_Desc);
        echo "Course Description Value is : ".$Course_Desc." ...Thanks";
    }
?>
<form method="post" name="implantForm">
<table >
    <input type="hidden" name="ProtocolID" id="Protocol">
    <tr align="Left">
        <td>
            <label style="color:#ff6600;font-weight:bold">
                Name
            </label>
        </td>
        <td>
            <label id="formLbl"></label>
        </td>
    </tr>
    <tr align="Left" style="color:#ff6600;font-weight:bold">
        <td>Protocol  </td>
        <td>
            <textarea id="formTXT" rows="4" cols="50" name="Course_Descr" form="implantForm"></textarea> 
        </td>
    </tr>
</table>
<table>
    <tr align="center" >
        <td>
            <input type="submit" name="saveEdites" value="Save changes">
        </td>
    </tr>
</table>
</form>

我声明form="implantForm"所以我把它删除了,现在一切都正常了

请将<form>标签放在您的程序中,并从<textarea>中删除form=implantForm。在这里我对代码进行了一些更改,然后我得到textarea值作为输出

<form>
<table >
    <input type="hidden" name="ProtocolID" id="Protocol">
    <tr align="Left">
        <td>
            <label style="color:#ff6600;font-weight:bold">
                Name
            </label>
        </td>
        <td>
            <label id="formLbl"></label>
        </td>
    </tr>
    <tr align="Left" style="color:#ff6600;font-weight:bold">
        <td>Protocol  </td>
        <td>
            <textarea id="formTXT" rows="4" cols="50" name="Course_Descr" ></textarea>

        </td>
    </tr>
</table>
<table>
    <tr align="center" >
        <td>
            <input type="submit" name="saveEdites" value="Save changes">
        </td>
    </tr>
</table>
</form>
<?php
     if (isset($_REQUEST["saveEdites"])) {
        $id = $_REQUEST['ProtocolID'];
        $Course_Desc = $_REQUEST['Course_Descr'];
        $Course_Desc = trim($Course_Desc);
        $Course_Desc = stripslashes($Course_Desc);
        $Course_Desc = htmlspecialchars($Course_Desc);
        echo "Course Description Value is : ".$Course_Desc." ...Thanks";
    }
    ?>

形式="implantForm"这就是让浏览器困惑的地方文本区域值甚至没有在请求中发送。删除它,现在一切都正常了

请从textarea中删除form="implantForm",这样就可以了