表格不提交

时间:2012-01-09 22:35:45

标签: php html forms

晚上好,

我有一个表格应该将我重定向到cart.php,但它不起作用。这是我的代码:

<tr align='center'>

            <td colspan='3'>
                <form method="post" action="cart.php">
                <input type="submit" name="action"  value="View Cart"/>
            <td>
        </tr>
        </form>
    </table>

单击该按钮时,它将保留在当前页面中。任何帮助请...当我把表格放在最后,这意味着它</body>工作之前。我在此代码之前有另一种形式:

<form method='post' action='xbox.php'>

                <input type='hidden' name='isPostBack' value='true'/>
                <input type='hidden' name='productid' value='$row[ProductId]'/>
                <tr align='center'>
                    <td>
                        <input type='text' name='qty' class='inputtext'/>
                        <input type='submit' name='action' value='Buy now'/>
                        </form>

有没有办法处理这两种形式并将第一种形式留在第二种形式之前?

3 个答案:

答案 0 :(得分:11)

你的html不正确,当你在输入后放置结束表格标签时它应该有效:

    <td colspan='3'>
        <form method="post" action="cart.php">
            <input type="submit" name="action"  value="View Cart"/>
        </form>
    </td>

您编辑过的html也没有验证,因此我强烈建议您使用有效的HTML。

无论如何,虽然你没有显示所有的html,但另一个问题可能是你有嵌套的表单。您可以在页面上有多个表单,但是在彼此之后,不能嵌套。所以这应该工作得很好:

<form method='post' action='xbox.php'>
...
</form>
...
<form method="post" action="cart.php">
    <input type="submit" name="action"  value="View Cart"/>
</form>

答案 1 :(得分:1)

HTML格式不正确。它应该是:

        <td colspan='3'>
            <form method="post" action="cart.php">
            <input type="submit" name="action"  value="View Cart"/>
            </form>
        <td>

答案 2 :(得分:0)

这是因为你有混合的标签。有时候它有效,因为解析器有点宽容,但它不合适。将您的标记放在输入标记下,并在下一个标记之前(顺便说一下,您的第二个标记也未关闭)