也不$ _POST,$ _ GET传递我的值

问题描述

| 我有一个foreach循环,列出了唯一的代码作为链接
<a href=\"#\" class=\"charcoal_link\" value=\"<?PHP echo $id_to ?>\" style=\"line-height: 20px;\" onclick=\"showMessageArea(this); return false;\">
<?PHP echo $uniqueCode1?>
    <span class=\"pink_text\"><?PHP echo $uniqueCode2?></span>
<?PHP echo $uniqueCode3?>
</a>
<input type=\"hidden\" name=\"id\" value=\"<?PHP echo $id_to ?>\" />
<form id=\"message_area\" style=\"display:none\" method=\"post\" action=\"<?PHP echo ADDRESS; ?>messageSent.PHP?id=<?PHP echo $id_to ?>\">
    <tr>
        <td>
            <input name=\"message\" type=\"textarea\" rows=\"10\" cols=\"20\" value=\"<?PHP echo $message ?>\" />
        </td>
        <td>
            <input name=\"Submit\" type=\"submit\" value=\"Send\" />
        </td>       
    </tr>
</form>
上面的也是另一种形式的标签
<form name = \"contacts\" method=\"post\">
动作部分工作正常,但在messageSent.PHP中,我这样做:
var_dump($_POST);
var_dump($_GET);
输出给我:
NULL
array(1) { [\"id\"]=> string(2) \"36\" }
“消息”在哪里? \“ id \”包含错误的ID。它不是我单击的唯一代码的ID。     

解决方法

        
    <a href=\"#\" class=\"charcoal_link\" value=\"<?php echo $id_to ?>\" style=\"line-height: 20px;\" onclick=\"showMessageArea(this); return false;\">
    <?php echo $uniqueCode1?>
        <span class=\"pink_text\"><?php echo $uniqueCode2?></span>
    <?php echo $uniqueCode3?>
    </a>
 <form id=\"message_area\" style=\"display:none\" method=\"post\" action=\"<?php echo ADDRESS; ?>messageSent.php?id=<?php echo $id_to ?>\">
    <input type=\"hidden\" name=\"id\" value=\"<?php echo $id_to ?>\" />

    <table>
        <tr>
            <td>
                <textarea name=\"message\" rows=\"10\" cols=\"20\"><?php echo $message ?></textarea>
            </td>
            <td>
                <input name=\"Submit\" type=\"submit\" value=\"Send\" />
            </td>       
        </tr>
    </table>
    </form>
您不能在表单中拥有表单..您必须将它们分开或以相同的形式进行.... 我为您修复了HTML标记     ,        您的HTML无效。在您犯的许多错误中:在表格内不能有表格,但在tr周围不能有表格。浏览器通过将form元素移动到允许的位置并保留输入(因为输入可以在td元素内部)来进行错误纠正。 验证。验证。验证。 您共享的HTML片段有很多问题,您可能会从编写网页的初学者指南中受益。