Multiple Submit buttons, how do determine which one was clicked?
html, php
Solution
Set `value` for each submit button and check that in php and find which one is clicked
<form method="POST">
<img src="http://www.foo.com/img.png" id="button_1" name="submit_btn" value="1">
<img src="http://www.foo.com/img.png" id="button_2" name="submit_btn" value="2">
<img src="http://www.foo.com/img.png" id="button_3" name="submit_btn" value="3">
<img src="http://www.foo.com/img.png" id="button_4" name="submit_btn" value="4">
...
<img src="http://www.foo.com/img.png" id="button_100" name="submit_btn" value="100">
</form>
`echo $_POST['submit_btn'];` will give you the value of which submit button is clicked
Problem
I have a form with multiple submit buttons. Each submit button is an `IMG SRC` trash can which denotes the delete icon for messages in a web based messaging mail inbox what is the best way to figure out which submit button icon was clicked so that I can then write the PHP/MySQL code to DELETE the message? ``` if(!empty($_POST)){ // How do I figure out which submit button has been clicked to get the ID of the message to delete? } <form method="POST"> <input src="http://www.foo.com/img.png" id="button_1"> <input src="http://www.foo.com/img.png" id="button_2"> <input src="http://www.foo.com/img.png" id="button_3"> <input src="http://www.foo.com/img.png" id="button_4"> ... <input src="http://www.foo.com/img.png" id="button_100"> </form> ```