Question

Using PHP, after a form has been submitted via "POST"...

I am trying to detect if an input type is HIDDEN.

FYI: Each hidden input has a different NAME and different ID.

Example:

<input type="hidden" id="uniqueID1" name="SomeName1" value="99" />

Any suggestions are welcome.

Was it helpful?

Solution 2

The only resolution that I found for this...

I created a jQuery function that would 'find' all HIDDEN fields prior to the form submitting the data. It would then create additional [new] HIDDEN fields with the input naming structure: name="hidden1" value="1" , name="hidden2" value="1" , etc. using a FOR loop. In my PHP processing code, it would 'see' all input values that begin with "hidden" as the field name and then do ... whatever with these hidden fields.

The bottom line... There is no way to have PHP detect file types of the input fields of a form **that is processing to another PHP page.

**FOOTNOTE: It may be possible to do this if a PHP page is submitting to itself! (I don't know. I didn't test this.)

OTHER TIPS

Do this:

Assign your all fields array names.

<input type="hidden" id="uniqueID1" name="hidden[SomeName1]" value="99" />

After form submit, in PHP.

<?php
if (! empty($_POST)) {
  foreach ($_POST as $k => $v) {
   if ($k == 'hidden') { // Here you get if the field is hidden one.
    if (! empty($v)) {
     foreach ($_POST as $hidName => $hidValue) {
     }
    }
   }
  }
}
?>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top