Im trying ot make this simple voting script work.
i want to use the file as an include to my index.php
include("includes/votes.php");
everything seems fine, but the votes do NOT get entered....something with the form action/post?
Teh data displays Correct, its just a VOTE does not update the db.
if ($vote && !$HelloCheater) {
mysql_connect($server,$db_user,$db_pass) or die("Database Connect Error");
$query = mysql_db_query($database,"update votes set votes=votes+1 where name='$vote'") or die("Database Query Error");
mysql_close();
setcookie("HelloCheater", "1", time()+(3600*$cookie_time));
header("Location: index.php");
exit;
}
?>
<?
echo "<form action=\"/includes/votes.php\" method=\"POST\">";
mysql_connect($server,$db_user,$db_pass) or die("Database Connect Error");
$result=mysql_db_query($database,"select sum(votes) as sum from votes") or die("Database Query Error");;
if($result) {
$sum = (int) mysql_result($result,0,"sum");
mysql_free_result($result);
}
$result=mysql_db_query($database,"select * from votes order by votes DESC") or die("Database Query Error");;
echo "<table border=0 width=$vote_width><tr><td class=\"sides\" colspan=\"3\">$vote_question<br><br></td></tr>
<tr><td class=\"black_text\">$vote_vote</td><td class=\"black_text\">$vote_answer</td>
<td class=\"black_text\">%</td></tr>\n";
while($row=mysql_fetch_row($result)) {
echo "<tr><td align=\"black_text\"><input type=radio name=vote value=\"$row[0]\"></td>";
echo "<td class=\"black_text\" colspan=\"2\">" .$row[0]."</td></tr><tr>
<td class=\"black_text\" align=\"center\">".$row[1]."</td><td class=\"black_text\">";
if($sum && (int)$row[1]) {
$per = (int)(100 * $row[1]/$sum);
echo "<table align=center border=0 cellspacing=0 cellpadding=1 width=\"$votebar_width\" height=\"$votebar_height\">\n";
echo " <tr>\n";
echo " <td class=\"votebarout\">\n";
echo " <table align=left border=0 cellspacing=0 cellpadding=0 width=\"$per%\" height=\"100%\">\n";
echo " <tr>\n";
echo " <td class=\"votebarin\">\n";
echo " <div class=\"votespace\"> </div>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo"</td><td class=\"black_text\">$per</td>";
}
echo "</tr>\n";
}
mysql_free_result($result);
mysql_close();
echo "<tr><td class=\"sides\" align =\"right\" colspan=\"3\"><input type=\"submit\" value=\"$vote_button\"></form></td></tr>";
echo "</table>\n";
?>