I have a form with Two buttons. It's a submit form which is basically there to increase/Decrease an Integer value in a MySQL database depending on which button they click.
This is a weird scenario, the page requires an ID extension;
appinfo.php?id=12
Whenever I click one of the buttons it changes the extension to:
appinfo.php?VoteYes=Yes
Ideally I'd like it so if someone clicks on Yes it will increase a value within an SQL query and if they click no, it will decrease it.
Here is what I have so far:
<form action="<?php echo $_SERVER['PHP_SELF'] . "?id=" . $_GET['id']; ?>"/>
<input id="submit" name="VoteYes" type="submit" value="Yes" class="btn btn-success"></input>
<input id="submit" name="VoteNo" type="submit" value="No" class="btn btn-warning"></input>
</form>
id. (You're also not validating that field.) What you're seeing happen is the name of the button you click on is getting added to the querystring. The approach I'd recommend is doing an ajax call on button click to a script that handles the logic of inserting data into the db. Then on the success callback you can update the form action or whatever you need to do.