- Code: Select all
$updatedisplayrating = "UPDATE item SET displayrating=itemrating/$sinceCreated WHERE itemid='$_POST[hiddenitemid]'";
// Defining button functions
if(isset($_POST['VoteButton'])){
$VoteQuery = "UPDATE item SET itemrating=itemrating+1 WHERE itemid='$_POST[hiddenitemid]'";
mysql_query($VoteQuery, $con);
mysql_query($updatedisplayrating, $con);
};
Here is what I use for the button. Note: $row_rs_ItemByNumber['itemid'] is used from Dreamweaver record set.
- Code: Select all
echo "<form action=index.php method=post>";
echo "<input type=hidden name=hiddenitemid value=" . $row_rs_ItemByNumber['itemid'];
echo "<td>" . "<input type=submit name=VoteButton value=Vote " . "</br>" . " </td>";
echo "</form>";
I was thinking I could use a second variable to solve the multiple submission problem. Thinking that the code runs on every page load and not every action on the page (button press). Something like this:
- Code: Select all
$i=0;
// Defining button functions
if(isset($_POST['VoteButton'])){
$i=1;
};
if($i=1){
$VoteQuery = "UPDATE item SET itemrating=itemrating+1 WHERE itemid='$_POST[hiddenitemid]'";
mysql_query($VoteQuery, $con);
mysql_query($updatedisplayrating, $con);
};
What is the reason that the second variable is still allowing multiple submissions? Wouldn't it just be setting $i=1 every time it's clicked and then running the if statement containing $VoteQuery to run only once per page load?


