VB icon

Poll With Bar Graph Results

Email
Submitted on: 1/1/2015 5:16:00 AM
By: Todd Williams (from psc cd)  
Level: Beginner
User Rating: By 2 Users
Compatibility: PHP 3.0, PHP 4.0
Views: 1046
 
     It is a Poll script all in 1 page. I didn't add a vote limit per person, because I couldn't find a secure way to do it. IP block isn't good because people can re-sign on and their IP will change. Cookies block isn't good because if they disable cookies they can vote as many times as they want. If you know another way please let me know.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Poll With Bar Graph Results
// Description:It is a Poll script all in 1 page. I didn't add a vote limit per person, because I couldn't find a secure way to do it. IP block isn't good because people can re-sign on and their IP will change. Cookies block isn't good because if they disable cookies they can vote as many times as they want. If you know another way please let me know.
// By: Todd Williams (from psc cd)
//**************************************

//#####!!!!!!!!resource.inc!!!!!!!!!!!!####
<?php
$item = array("1", "1", "1");
?>
//#########################################
//#########################################
//#########################################
//######!!!!!!!!poll.php4!!!!!!!!!!!!######
<html>
<head>
<title>Graphical Poll - By: Todd Williams</title>
</head>
<body text="white">
<table border="1" bordercolor="red" cellspacing="0" bgcolor="black">
<tr><td colspan="3" align="center">Title of Poll</td></tr>
<tr>
<td colspan="3">
<?php
include("resource.inc");
$name = array ("Item 1", "Item 2", "Item 3");
$percent = array ("","","");
$total = $item[0] + $item[1] + $item[2];
if ($addto)
{
 switch ($addto)
 {
 case "item0":
 $item[0] = $item[0] + 1;
 break;
 case "item1":
 $item[1] = $item[1] + 1;
 break;
 case "item2":
 $item[2] = $item[2] + 1;
 break;
 }
 $fp = fopen ("resource.inc", "wb"); 
 $string = "<?php\n\$item = array(\"$item[0]\", \"$item[1]\", \"$item[2]\");\n?>";
 fwrite($fp, $string);
 fclose ($fp);
}
for ($i=0; $item[$i]; $i++)
{
$percent[$i] = ($item[$i] * 100) / $total;
		//list ($before, $after) = split (".",$temp) //before now contains everything before the decimal
		//$percent[$i] = $before
}
echo "Current Results:";
echo "</td></tr>\n";
echo "<tr><td>$name[0]</td><td>$name[1]</td><td>$name[2]</td></tr>\n";
echo "<tr align=\"center\" valign=\"bottom\" height=\"100\">\n";
for ($i=0; $item[$i]; $i++)
{
echo "<td>$item[$i]";
echo "<table><tr height=\"$percent[$i]\" width=\"20\" bgcolor=\"red\"><td> </td></tr></table></td>\n";
}
echo "</tr>\n";
?>
<tr>
<td colspan="3">
<form action="poll.php4">
<?php
for ($i=0; $name[$i]; $i++)
{
echo "<input type=\"radio\" name=\"addto\" value=\"item$i\">$name[$i]</input><br>\n";
}
?>
<input type="submit" value="send">
</td>
</form>
</table>
</body>
</html>


Other 3 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments


 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.