Full-service Internet Marketing & Web Development
Recent Posts

Sponsors
![]() |
Simple Vote ScriptCode Wizard, 12-30-2006 |
This is a simple vote then view script, there was probably 9 million other easiers ways to do it, but this is how I looked at it. So check it out.
This is one of my first REAL scripts, please give me some feedback as to how possibly to make it better, or just what you don't like about it. Thanks.
<html>
<body bgcolor="#000000" link=#FFFFFF alink=#FFFFFF vlink=#FFFFFF>
<?PHP
// Vote Script
// Created
// by: KrIsPy
// on: 5.11.01
// Use however you want, just include my name plz. TY
// BEFORE using this script, just m,ake a file called votelist.php3 a zero on the first 4 lines, and nothing else.
function vote($vote, $exp){
$count = 0;
$votelist = "votelist.php3";
$fpr = fopen($votelist, "r");
$fpa = fopen($votelist, "a");
while (! feof($fpr))
{
$count++;
$voteline = fgets($fpr, 1024);
if ($count != $vote)
{
$fpw = fopen($votelist, "w");
fwrite($fpa, "$voteline");
}
if ($count == $vote) {
settype($voteline, "integer");
print "<font size=1 face=tahoma color=#FFFFFF>you chose $exp<br><br>";
$voteline++;
print "There are now $voteline vote(s) for $exp<br>";
print "<br><br><a href=vote.php3>Click here to go back to the main page plz. ;)</a>";
fwrite($fpa, "$voteline
");
}
}
}
if($vote == 1) {
vote($vote, $exp);
}
elseif($vote == 2) {
vote($vote, $exp);
}
elseif($vote == 3) {
vote($vote, $exp);
}
elseif($vote == 4) {
vote($vote, $exp);
}
else {
print "<font size=1 face=tahoma color=#FFFFFF><center>";
print "<b>Welcome to leetvote.</b><p></center>";
print "Please select what you think of this site.<br><br>
<a href=vote.php3?vote=1&exp=It's+god+like!>It's god like!</a><br>
<a href=vote.php3?vote=2&exp=It's+good.>It's good.</a><br>
<a href=vote.php3?vote=3&exp=It's+bad.>It's bad.</a><br>
<a href=vote.php3?vote=4&exp=LOL,+you're+kidding+righ t.>LOL, you're kidding right?</a><br><br>
<a href=vote.php3?view>Or click here to view current results.</a><br>
";
$votelist = "votelist.php3";
$fpr = fopen($votelist, "r");
$count = 0;
$total = 0;
print "<p><p><p><font size=1 face=tahoma color=#FFFFFF><b>Current Vote Resultz:</b><br><br>";
while (! feof($fpr))
{
$count++;
$voteline = fgets($fpr, 1024);
settype($voteline, "integer");
$total += $voteline;
}
$votelist = "votelist.php3";
$fpr = fopen($votelist, "r");
$count = 0;
while (! feof($fpr))
{
$count++;
$voteline = fgets($fpr, 1024);
settype($voteline, "integer");
print "<font size=1 face=tahoma color=#FFFFFF>";
if ($count == 1) {
$percent = $voteline * 100;
$percent = $percent / $total;
settype($percent, "integer");
print "there are $voteline vote(s) for It's god like! ($percent%)<br>";
}
if ($count == 2) {
$percent = $voteline * 100;
$percent = $percent / $total;
settype($percent, "integer");
print "there are $voteline vote(s) for It's good. ($percent%)<br>";
}
if ($count == 3) {
$percent = $voteline * 100;
$percent = $percent / $total;
settype($percent, "integer");
print "there are $voteline vote(s) for It's bad. ($percent%)<br>";
}
if ($count == 4) {
$percent = $voteline * 100;
$percent = $percent / $total;
settype($percent, "integer");
print "there are $voteline vote(s) for LOL, you're kidding right? ($percent%)<br>";
}
}
}
?>
</body>
</html>
|
|
Subscribe Now to receive new posts via Email as soon as they come out.
Comments
Post your comments

