Get the name of submit button in PHP

后端 未结 3 1018
粉色の甜心
粉色の甜心 2021-01-05 13:55

How do I get the name of the submit button in PHP?

I got the value of submit button, but I could not find any code to get the name of the button. Below is the code I

相关标签:
3条回答
  • 2021-01-05 14:41

    'submitbutton' is the name of your submit button. you can get the names of super global $_POST array elements with array_keys() function

    $postnames = array_keys($_POST);
    
    0 讨论(0)
  • 2021-01-05 14:47

    You will find the name in the $_POST array.

    <?php
    print_r($_POST);
    ?>
    

    This way you will see everything in the $_POST array.

    You can iterate through the array with:

    foreach($_POST as $name => $content) { // Most people refer to $key => $value
       echo "The HTML name: $name <br>";
       echo "The content of it: $content <br>";
    }
    
    0 讨论(0)
  • 2021-01-05 14:49

    Its like any other POST variable, the name will be in the $_POST array. The name is the key in the $_POST array.

    0 讨论(0)
提交回复
热议问题