Get the name of submit button in PHP

人走茶凉 提交于 2019-11-30 14:48:11

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>";
}

'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);

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!