views:

55

answers:

3

Hi guys, I have index.php:

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

modules/*some_module*.php

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

update_db.php:

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

After loading index.php i see need form. But during submitting i'm coming to the same page (index.php). Why?


http:/****/admin/

Here is html-code generated: http://dpaste.com/93396/


It's so strange, but form generates 2 times... I removed all part of code and rewrited it. Now everything is fine. Thanks all.

A: 

Would probably need to see it in action. Can you link to it? You can always remove the link once you have the answer you need.

Julian Young
this should be posted as a comment, not an answer
Natrium
@Natrium, I agree (hence the upvote) but bear in mind that Julian may not have sufficient rep to leave comments yet. (I can't remember what the threshold is.)
David Thomas
ok, valid argument.
Natrium
Thanks for pointing that out folks
Julian Young
Hmm I can comment on comments but can't comment if a comment doesn't exist it seems.
Julian Young
+1  A: 

I took a look at your site. Your form action is index.php and that is why you keep seeing the same page after you click submit. If your code above is correct, ensure that you do not have <form> tags in your module containing the submit button.

<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>
hoffmandirt
And that page isn't need. It's just login-window. The next will be that, what I need
Ockonal
the problem isn't in the login, but on the next page. taht's what he's trying to say. (the form with 6 inputfields)
Natrium
In original form element action attribute has different value (update_db.php) then above. And here is the problem. Set proper action value and it will work. Redirect could drop values of form.
Grzegorz Gierlik
A: 

you have this:

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

not this:

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

Change it and your form will post to update_db.php

Natrium