www.tehdot.com/az.php
I want to make it so that someone can only vote once...and I almost have it, there is just something that isnt working...if someone could help, that would be great.
Ok, Ive implemented an IP logger that works fine, from my friends experience, and I include it....it was working before, but I had to seperate my queries and create a new one, since the first query only selects the last item on the table, and as long as you werent the last chooser, you could vote again. Now it does not work, it doesnt error and it records the thing, even if you have already voted.
I am not sure why.
here is the code:
<?
ob_start();
include('includes/connect.php');
include('includes/iplog.php');
?>
<BODY BGCOLOR="cccccc">
<center>
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2 ,0" width="700" height="245">
<param name=movie value="siteloaded.swf">
<param name=quality value=high>
<param name="wmode" value="Transparent">
<embed src="siteloaded.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi? P1_Prod_Version=Shockwave
Flash" type="application/x-shockwave-flash" width="700" height="245">
</embed>
</object>
<FONT FACE="verdana">
<BODY BGCOLOR="cccccc">
<TABLE BORDER="0" width="688" CELLSPACING="0" CELLPADDING="0">
<tr><td COLSPAN="4" valign="top"></td></tr>
<TR width="688"><td width="20"></td><td width="25" > <IMG SRC="images/bar.gif"></td>
<td align="center" valign="top"><div layer style="width:608px; height: 235px; overflow:auto;">
<br></b><A HREF="downloads/absolutezero.zip">Absolute Zero</A><br><FONT SIZE="-1">A great, mellow, ambeince song that sounds like you are in an ice dungeon in an RPG game. It is a great song, and I think you will enjoy it.<br>
<?
echo"<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">";
echo"1<INPUT TYPE=\"radio\" NAME=\"rateaz\" VALUE=\"1\">   2<INPUT TYPE=\"radio\" NAME=\"rateaz\" VALUE=\"2\">   3<INPUT TYPE=\"radio\" NAME=\"rateaz\" VALUE=\"3\">   4<INPUT TYPE=\"radio\" NAME=\"rateaz\" VALUE=\"4\">   5<INPUT TYPE=\"radio\" NAME=\"rateaz\" VALUE=\"5\">   ";
$querya="SELECT * FROM az ORDER BY number DESC LIMIT 1";
$resulta = mysql_query($querya);
$row = mysql_fetch_array($resulta, MYSQL_BOTH);
$queryb="SELECT ip FROM az";
$resultb = mysql_query($queryb);
$rowb = mysql_fetch_array($resultb, MYSQL_BOTH);
$average = $row['average'];
if($rateaz){
$vote = $rateaz;
$total = $row['total'];
if(isset($total)){
$number = $row['number'];
$average = ($vote + $total) / ($number + 1);
$total= $total + $vote;
}
}
echo"<br><INPUT TYPE=\"submit\" NAME=\"submit\" VALUE=\"Vote Now\"><br><Br>";
echo"<br>There have been votes so far. <br> The average score of this song is <b>".$average."</b>";
?>
</td>
<td width="30"><IMG SRC="images/barother.gif"></td></tr>
<tr><td width="20"></td><td width="668" COLSPAN="3" valign="top"> <IMG SRC="images/barbot.gif"> <IMG SRC="images/ball.gif"> <IMG SRC="images/endpieceleft.gif"><IMG SRC="images/bottomthing.gif"><IMG SRC="images/bottomthing.gif"><IMG SRC="images/piece.gif"><IMG SRC="images/piece.gif"><IMG SRC="images/piece.gif"><IMG SRC="images/piece.gif"><IMG SRC="images/piece.gif"><IMG SRC="images/tinypiece.gif"><IMG SRC="images/small.gif"><IMG SRC="images/bottomother.gif"></td></tr>
<?
if(isset($_POST['submit'])){
if($rateaz < 1){
echo"<script>
window.alert(\"Please pick an option.\")
</script>";
}
else
{
if($ip != $rowb['ip']){
$queryc="INSERT INTO az (average, total, votes, ip) VALUES ('$average','$total','$vote','$ip')";
$resultc= mysql_query($queryc);
}
else
{
echo"<script>
window.alert(\"You have already voted and may not vote again.\")
</script>";
}
}
}
?>
I think it has something to do with these lines:
$rowb = mysql_fetch_array($resultb, MYSQL_BOTH);
and
if($ip != $rowb['ip']){
Thanks..