Determining Button used to Submit with PHP

后端 未结 2 1427
庸人自扰
庸人自扰 2021-01-26 09:10

I am creating a management engine that needs to manage sections and then pages within the sections.

For usability it has been decided that the display order fields will

2条回答
  •  萌比男神i
    2021-01-26 09:36

    Instead of having a different name attribute for your buttons, i suggest that you keep the name the same eg name="edit_btn".

    Then you can simply put the ID in the buttons value attribute and read it with $_POST['edit_btn'] on the PHP side.

    html:

    
    

    PHP:

    var_dump($_POST['edit_btn']);
    

    If you for some reason INSIST on keeping the ID in the NAME, you COULD do something like this instead:

    HTML:

    
    

    PHP:

    var_dump(key($_POST['edit_btn']));
    

提交回复
热议问题