Syntax errors aside, you can give the two buttons the same name, but different values.
echo '<form method="post" action="___URL OF YOUR PAGE___">';
echo '<input type="submit" id="up_vote" name="vote" value="Like" /> OR';
echo '<input type="submit" id="down_vote" name="vote" value="Dislike" />';
echo '</form>'
...
if($_POST['vote'] == "Like") {
...
} else if ($_POST['vote'] == "Dislike") {
...
}
Note that I changed the input
's type
to submit
instead of button
. This will cause the data to send itself to the page (button
won't do anything unless you start adding JavaScript).
You can read more about this in these answers: