Known problems with hidden fields and forms?
Moderator: General Moderators
Known problems with hidden fields and forms?
I have a form that only contains one field and its hidden. This is used so that we can use submit buttons to select which option the person wants. I realize there are more practical ways to do this but I am reconfiguring a script and eventuall will re-do it better, but for the time being this is how it is done. The script worked previously, but after recently upgrading to a newer version of PHP I have run into a rather odd problem. When I pass one hidden field in via POST and output it on the next name it shows up in the form as name=value (of course it should just be value). If I add a second hidden field to the form and run it, everything works fine. Has anyone heard of or seen this problem before? Is there anything I can do/try short of adding a dummy hidden field to each form this is used in?
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Form Code:twigletmac wrote:Could we see the form code and the bit of code you use to display it on the next page?
Mac
Code: Select all
<form method="POST" action = "options.php">
<input type="hidden" name="machine" value="thisone" />
<input type="submit" value="Select" /> This one (This one)
</form>Code: Select all
<font size="2" color="black">Test: <?=$machine?></font><br />- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Have you tried:
(note that the forum decided to remove the closing php tag - ? >)
and what do you get if you put
at the top of the form processing page?
Mac
Code: Select all
<font size="2" color="black">Test: <?php echo $_POST['machine']; ?></font><br />and what do you get if you put
Code: Select all
echo '<pre>';
print_r($_POST);
echo '</pre>';Mac
you might want to try
is mbstring or another conversion active?
- php.ini: always_populate_raw_post_data = On
- or .htaccess: php_flag always_populate_raw_post_data On
Code: Select all
<html><body>
<?php echo htmlentities($HTTP_RAW_POST_DATA); ?>
<form method="POST">
<input type="hidden" name="machine" value="one" />
<input type="hidden" name="machine" value="two" />
<input type="submit" value="Select" />
</form>
</body></html>That code doesn't output anything.....volka wrote:you might want to tryto see what $HTTP_RAW_POST_DATA contains.
- php.ini: always_populate_raw_post_data = On
- or .htaccess: php_flag always_populate_raw_post_data On
is mbstring or another conversion active?Code: Select all
<html><body> <?php echo htmlentities($HTTP_RAW_POST_DATA); ?> <form method="POST"> <input type="hidden" name="machine" value="one" /> <input type="hidden" name="machine" value="two" /> <input type="submit" value="Select" /> </form> </body></html>
it only does if always_populate_raw_post_data is enabled.
check withthe local value for always_populate_raw_post_data must be 1
e.g.
check with
Code: Select all
<? phpinfo(); ?>e.g.
Code: Select all
Configuration
PHP Core
Directive Local Value Master Value
allow_call_time_pass_reference Off Off
allow_url_fopen 1 1
always_populate_raw_post_data 1 0
arg_separator.input & &
arg_separator.output & &Upoon testing the output of what you told me to I got:volka wrote:it only does if always_populate_raw_post_data is enabled.
check withthe local value for always_populate_raw_post_data must be 1Code: Select all
<? phpinfo(); ?>
e.g.Code: Select all
Configuration PHP Core Directive Local Value Master Value allow_call_time_pass_reference Off Off allow_url_fopen 1 1 always_populate_raw_post_data 1 0 arg_separator.input & & arg_separator.output & &
VALUEmachine=VALUE;
Now, I guess I just have to put an extra data field in that does nothing, although I don't know why. Could this problem and the other problem I am having with uploading files be contributed to a bad install of PHP?