When a vote value is changed, the form POSTs the change, then refreshes the page. This is called on the top of the page upon load:
if (isset($_POST['q'.$question_id]))
{
$user->updateQuestionVotes($question_id, $_POST['q'.$question_id]);
}
Why does it update every time I refresh after the first time? Do I need to unset it some开发者_开发知识库how?
Because that's the natural behavior of every browser. You need to redirect the user to the same page so that the POST values will not be in the header anymore.
Have you tried this?
header("Location: /back/to/same/page");
This will redirect the user to whatever page they need to land back on, removing any POST parameters that they sent. Any time you refresh a page, it uses the same headers as before, which means the POST content will still be there.
精彩评论