I have discovered something really strange.
That if I have a field with value hidden, I can’t get the value using $_POST[‘’] in the next page.
Anyone aware about this issue and a workaround?
I have discovered something really strange.
That if I have a field with value hidden, I can’t get the value using $_POST[‘’] in the next page.
Anyone aware about this issue and a workaround?
<form method="post">
<input type="hidden" value="test" name="f" />
<input type="submit" />
</form>
<?php
echo('<br /><br />'.$_POST['f']);
?>
Place this code in a php file and test it. If it works can you see what you did wrong ?
If it doesnt work then i havnt a clue…sorry. After submitting the output after the form should be “test” without quotes.
<input> must have a name to access it from $_POST.
This is working monkey56657. And I am really clueless here why in my case the hidden value is not coming. There’s nothing wrong apparently, as on removing the hidden the value is getting submitted properly.
BTW, are you always using the format echo()? Because, echo is not a function, it’s a language construct and in strict sense it should not be put with parentheses.
echo ‘test’; rather than echo (‘test’);
More info here.
I prefer to use brackets as it allows be to see whats going on better when there is lots of code in a short space. Personal preference. I have also never needed to pass more than 1 string to be output, i just use a . to join together.
ah, ok. I understand.
Hi kigoobe,
Is the field inside the <form> tags?
Is the form method set to post, not get?
Are you sure your syntax for <input> is correct>? (<input type=“hidden” name=“field” value=“value” />)
At the beginning of your script, add these two lines:
error_reporting(E_ALL);
ini_set('display_errors', 1);
Perhaps there’s an error elsewhere in your PHP script. With error reporting set to E_ALL you’ll see if there is one.
Hope this helps.
Cheers,
Pepe
Hi Pepe, thanks for your post.
No, basically the issue was with disabled attribute, I never had to work on this before and didn’t know.