与HTML格式的麻烦

时间:2009-09-14 12:33:45

标签: php html forms action

的index.php:

    <form action="update_db.php" method="post">
    <?php
        require_once 'modules/' . $currentModule . '.php';
    ?>      
    </form>  

模块/ some_module .PHP

...
<input type="submit" />
...

update_db.php:

@extract( $_POST );
print_r( $_POST );

加载index.php后,我看到需要表格。但在提交期间我来到同一页面(index.php)。为什么呢?


HTTP:/ **** /管理/

以下是生成的html代码:http://dpaste.com/93396/


这很奇怪,但表单会生成2次......我删除了所有代码并重新编写了代码。现在一切都很好。谢谢大家。

2 个答案:

答案 0 :(得分:1)

我看了一下你的网站。您的表单操作是index.php,这就是您单击提交后看到同一页面的原因。如果上面的代码是正确的,请确保模块中没有包含提交按钮的<form>标记。

<form action="index.php" method="post">
<table align="center">

    <tr>
        <td>Логин: </td>
        <td><input type="textfield" name="login" /></td>
    </tr>
    <tr>
        <td>Пароль: </td>
        <td><input type="password" name="password" /></td>
    </tr>

    <tr>
        <td></td>
        <td align="right"><input type="submit" name="submit" value="вход" /></td>
    </tr>
<table>
</form>

答案 1 :(得分:0)

你有这个:

<form action="index.php" method="post">

不是这个:

<form action="update_db.php" method="post">

更改它,您的表单将发布到update_db.php