1

There is an example what I want to do: http://www.w3schools.com/html/tryit.asp?filename=tryhtml5_input_type_datetime

In this example, if you change the input's name, on the right side of screen (after submitting code), you'll see the changed name. And also, as you can see there is no hidden input field to get the name of input automatically. Because I searched for some answers and they say "use an hidden input field" like in this: How to access the form's 'name' variable from PHP But I need it exactly in the w3schools.

Of course this is an .asp example but I hope there is a way for this via PHP also? Thanks in advance.

Community
  • 1
  • 1
Who Cares
  • 205
  • 5
  • 18

3 Answers3

1

To get all input field name using post method.

you can use $GET or $REQUEST instead of $POST.

$REQUEST use with both GET and POST. In php $POST is a one type of associative array.

<?php
$temp= array();
if (isset($_POST['submit']) && !empty($_POST['submit'])) {
    foreach ($_POST as $key => $val) {
        //$key is the name you wanted, and $val is the value of that input
        $temp[] = $key;
    }
}
?>
i'm PosSible
  • 1,373
  • 2
  • 11
  • 30
0
<?php
    foreach($_POST as $key => $val) {
        print $key . " = " . $val;
     }
 ?>
rakeshjain
  • 1,791
  • 11
  • 11
-1
$_GET['bdaytime'];

using the above code.

Janaka Dombawela
  • 1,337
  • 4
  • 26
  • 49