I’m making a facemash analog and I came across with an issue. When I vote for second image, the winner is the first one anyway. Where’s the problem? Web-site: http://facemash123.shimansky.ru
<form METHOD=POST ACTION="rate.php">
<table width="auto" align="center">
<tr align="center" width="auto" valign="top">
<td><img src="images/<?=$images[0]->filename?>" /></td>
<td><img src="images/<?=$images[1]->filename?>" /></td>
</tr>
<tr>
<td><input type="submit" name="winner" value="Vote"></td>
<td><input type="submit" name="winner" value="Vote"><td>
<input type="hidden" name="first" value="<?=$images[0]->image_id?>">
<input type="hidden" name="second" value="<?=$images[1]->image_id?>">
</tr>
<tr>
<td><center>Wins: <?=$images[0]->wins?>, Fails: <?=$images[0]->losses?></center></td>
<td><center>Wins: <?=$images[1]->wins?>, Fails: <?=$images[1]->losses?></center></td>
</tr>
</table>
</form>
rate.php http://jsfiddle.net/Rg7vf/
index.php http://jsfiddle.net/ad3PM/
THANKS in advance!
Your two submit buttons submit the same value, and there’s no way to differentiate between the two images.
Maybe change the code to:
and then in the vote handling code: