0

I'm trying to get the $_POST value from a previous page.

<form method="POST">
<input type="checkbox" name="hey"<?php if (isset($_POST['hey'])) echo " checked"; ?>>
<input type="submit">
</form>

And any values must be kept in the hidden form, and it makes that the form values doesn't update if you change a check:

<form method="POST">
<?php
if ($_POST['hey'] == 'on') {
?>
<input type="hidden" name="hey" value="on" />
<?php
}
?>
<input type="checkbox" name="hey"<?php if (isset($_POST['hey'])) echo " checked"; ?>>
<input type="submit">
</form>

This structure may sound weird (due to the CMS specification), anyway, if it changes I have to get input values, not hidden values, and all hidden forms should be written in the source. Any idea?

4
  • they will be in the $_POST array Commented Nov 14, 2011 at 2:44
  • 3
    I feel I could help you with this, but I'm having some difficulty understanding your requirement. Could you explain this: 'And any values must be kept in the hidden form, and it makes that the form values doesn't update if you change a check:' Commented Nov 14, 2011 at 2:45
  • there is no difference in the input type, the values are retrieved the same way regardless of type Commented Nov 14, 2011 at 2:47
  • @xbonez I mean, "any $_POST values must be available in hidden, but so that you can't get any changes from input forms. Need to get the changes with ignoring hidden values." Is it clear? Commented Nov 14, 2011 at 2:59

1 Answer 1

1

You use plural - so I assume it would be two or more variables. Set one hidden field in second page form call it previous_variables, put there all previous variables with their names, serialized, or as JSON string, when form submitted, unserialize or decode JSON, as start point and override if new values on second form happens to be more actual...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.