No POST data returned if there is a hidden input type

I think there is either an error in my code, or my PHP or Apache is not configured correctly.

When I submit a form with a hidden field, I get no data in my $ _POST array ...

When I comment on a hidden field in my code, the POST data will return correctly ...

HTML FORMAT

<form action='/utils/login.php ' method='POST'>
<table>
    <tr>
        <td colspan='2'>
            Login
        </td>
    </tr>
    <tr>
        <td>
            Username
        </td>
        <td>
            <input type='text' name='userid' value='' size='12' />
        </td>
    </tr>
    <tr>
        <td>
            Password
        </td>
        <td>
            <input type='password' name='password' size='12' />
        </td>
    </tr>
    <tr>
        <td>
            <input type='hidden' name='formtype' value='login' />
        </td>
    </tr>
    <tr>
        <td>
            <input type='submit' value='Submit' />
        </td>
    </tr>
</table></form>

Here is the code that processes it in PHP ...

foreach ($_POST as $var => $value) {
     echo "$var = $value<br>";
} 

I am using PHP 5 and Apache 2.2 on my server.

Any ideas?

EDIT ...

I narrowed it down to this ...

$command = $_POST['formtype'];

When I removed the @ sign from my $ _POST, I get the following error ...

Note: Undefined: formtype variable in C: \ webroot \ utils \ login.php on line 17

If I comment on this line, the POST data is passed to the program without problems.

+5
5

, , $_POST :

print_r($_POST);

, , , w/echo, .

, , , html.

+2

<form>.

, - . , .

+2

?

:

var_dump($_POST);

... -.

, - POST... :

variable = 'default';
if(isset($_Post['variable'])) $variable = $_POST['variable'];

... , .

+2
source

I changed my form for working with Twig. The modified form did not send a hidden input value with a message. If anyone has the same problem, I solved it by doing the following.

Source line:

<input hidden name='foo[{{ loop.index }}][id]' value='{{id}}' />

I sold it by making type = 'hidden':

<input type='hidden' name='foo[{{ loop.index }}][id]' value='{{id}}' />
+1
source

Try:

<form action="..." method="post" enctype="application/x-www-form-urlencoded">
0
source

All Articles