Give each input
a name
attribute. Only the clicked input
's name
attribute will be sent to the server.
<input type="submit" name="publish" value="Publish">
<input type="submit" name="save" value="Save">
And then
<?php
if (isset($_POST['publish'])) {
# Publish-button was clicked
}
elseif (isset($_POST['save'])) {
# Save-button was clicked
}
?>
Edit: Changed value
attributes to alt
. Not sure this is the best approach for image buttons though, any particular reason you don't want to use input[type=image]
?
Edit: Since this keeps getting upvotes I went ahead and changed the weird alt
/value
code to real submit inputs. I believe the original question asked for some sort of image buttons but there are so much better ways to achieve that nowadays instead of using input[type=image]
.