im VERY new with php and i have been working on a site... i want to add a poll but i am stuck!
Here is topgames.php
Then this is vote.phpPHP Code:<?php
mysql_connect("localhost", "(removed username)", "(pass removed for security reasons)") or die(mysql_error());
mysql_select_db("demonic_vote") or die(mysql_error());
$ip = "$HTTP_SERVER_VARS[REMOTE_ADDR]";
$Awesome=mysql_query("select * from results where Awesome='$Awesome'");
$Ok=mysql_query("select * from results where Ok='$Ok'");
$Terrible=mysql_query("select * from results where Terrible='$Terrible'");
$dupe1 = mysql_query("select * from results where ip='$ip'");
if ($dupe1 > 0) {
?>
<font color="00ff00"><center>Results:<br>
<h4>Awesome Votes: <?php print($Awesome) ?><br>
Ok Votes: <?php print($Ok) ?><br>
Terrible Votes: <?php print($Terrible) ?></h4></center></font>
<?php
}
else
{
?>
<center><form action="vote.php" method="post">
<font color="#00ff00">Vote that this game is</font> <font color="#FFFF00">Awesome:</font> <input type="radio" name="Vote" value="Awesome"><br>
<font color="#00ff00">Vote that this game is</font> <font color="#FFFF00">Ok:</font> <input type="radio" name="Vote" value="Ok"><br>
<font color="#00ff00">Vote that this game is</font> <font color="#FFFF00">Terrible</font>: <input type="radio" name="Vote" value="Terrible"><p>
<input type="submit" value="Vote" name="Vote">
</form></center>
<?php
}
?>
Lastly the MYSQL tablePHP Code:<?php
mysql_connect("localhost", "(removed username)", "(pass removed)") or die(mysql_error());
mysql_select_db("demonic_vote") or die(mysql_error());
$Awesome=mysql_query("select * from results where Awesome='$Awesome'");
$Ok=mysql_query("select * from results where Ok='$Ok'");
$Terrible=mysql_query("select * from results where Terrible='$Terrible'");
if (isset($_POST['submit'])) {
if ($_POST['Awesome'])
{
mysql_query("UPDATE * results SET Awesome=Awesome+1 WHERE Awesome='$Awesome'")
or die(mysql_error());
echo "Voted <a href=\"topgames.php\">Go to topgames</a>";
exit;
}
elseif ($_POST['OK'])
{
mysql_query("UPDATE * results SET Ok=Ok+1 WHERE Ok='$Ok'")
or die(mysql_error());
echo "Voted <a href=\"topgames.php\">Go to topgames</a>";
exit;
}
elseif ($_POST['Terrible'])
{
mysql_query("UPDATE * results SET Terrible=Ok+1 WHERE Terrible='$Terrible'")
or die(mysql_error());
echo "Voted <a href=\"topgames.php\">Go to topgames</a>";
exit;
}
}
?>
Something happened... <a href="topgames.php">Go back</a>
if any of you smart coders out there could help it would be great... you see i tried writing this code with logic, not syntax, and i completely messed upCode:CREATE TABLE `results` ( `id` int(11) NOT NULL auto_increment, `ip` int(20) NOT NULL default '1.1.1.1', `Awesome` int(30) NOT NULL default '0', `Ok` int(30) NOT NULL default '0', `Terrible` int(30) NOT NULL default '0', UNIQUE KEY `id` (`id`) ) TYPE=MyISAM AUTO_INCREMENT=1 ;
again PLEASE help... this is one of the first things i coded without a wizard and its difficult it is



Reply With Quote



Bookmarks