I've a poll form:
<?php
echo "ID: ",$id_vote, "<p>";
echo "Please press YES if you are agree with the entry or press NO if you are not agree and then fill the form.<br>";
?>
<form name="vote_form" method="post" action="<?php echo $action_url ?>">
<input type="submit" name="vote_form_yes" id="vote_form_yes" value="Yes">
<input type="submit" name="vote_form_no" id="vote_form_no" value="No">
</form>
<?php
if (isset($_POST['vote_form_yes']) && $_POST['vote_form_yes']==TRUE) {
$sql_run_vote_yes = "UPDATE MyTable SET id_votes_yes = id_votes_yes+1 WHERE id='$id_vote' ";
.......................................
.......................................
} else if (isset($_POST['vote_form_no']) && $_POST['vote_form_no']==TRUE) {
$sql_run_vote_no = "UPDATE MyTable SET id_votes_no = id_votes_no+1 WHERE id='$id_vote' ";
.......................................
.......................................
}
?>
Each button execute a mySQL query as you can see.
Unfortunatelly if I press "Yes" or "Not" I won't be redirected to another webpage but I still stay in that page with the chance to press "Yes" or "No" again and again and this is not good.
Do you have any hint how to block the "Yes" or "No" button after the first click?
I don't have any idea, so I thought to create 2 separated files, one with the form and one with the check and the query execution, like below:
File_1.php
<?php echo "ID: ",$id_vote, "<p>"; echo "Please press YES if you are agree with the entry or press NO if you are not agree and then fill the form.<br>"; ?> <form name="vote_form" method="post" action="<?php echo $action_url ?>"> <input type="submit" name="vote_form_yes" id="vote_form_yes" value="Yes"> <input type="submit" name="vote_form_no" id="vote_form_no" value="No"> </form>
File_2.php
<?php
if (isset($_POST['vote_form_yes']) && $_POST['vote_form_yes']==TRUE) {
$sql_run_vote_yes = "UPDATE MyTable SET id_votes_yes = id_votes_yes+1 WHERE id='$id_vote' ";
.......................................
.......................................
} else if (isset($_POST['vote_form_no']) && $_POST['vote_form_no']==TRUE) {
$sql_run_vote_no = "UPDATE MyTable SET id_votes_no = id_votes_no+1 WHERE id='$id_vote' ";
.......................................
.......................................
}
?>
Unfortunately if I do this way the "isset($_POST['vote_form_yes'])" and "isset($_POST['vote_form_no'])" are not verified and it doesn't work.
Any help please??
Thank you in advance
P.S.: already tried onclick, or the link in the action="", but it doesn't execute the queries.


Sign In
Create Account


Back to top









