Home > Backend Development > PHP Tutorial > PHP opinion voting box suitable for personal homepage_PHP tutorial

PHP opinion voting box suitable for personal homepage_PHP tutorial

WBOY
Release: 2016-07-13 17:23:42
Original
807 people have browsed it

For moderators, it is very useful information to know whether their homepage is popular, what aspects are popular, what aspects need to be improved, etc. Putting an opinion voting box on your homepage can collect visitors' opinions in a timely manner, which will be of great help to the construction of the website. Below is an opinion ballot box page written in PHP. This page will be refreshed after each vote to display the number and percentage of various votes.

----------------------vote.php------------------ ----------


Please vote




if(isset($Submit)) //If new content is submitted
{
if(!file_exists("voterec.txt"))
{
/ /The number of votes is 0
$voterec = array(0, 0, 0, 0, 0);
}
else
{
//Read the voting record
$voterec = file("voterec.txt");
}
//Update voting record
$voterec[$vote - 1] += 1;
//Write new vote Record
$fp = fopen("voterec.txt", "w+");
$total = 0;
for($i = 0; $i {
$voterec[$i] = chop($voterec[$i]);
$total += $voterec[$i];
fwrite($fp, $voterec[$i] ." ");
}
fclose($fp);
}
?>



www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/532200.htmlTechArticleFor each moderator, whether your homepage is popular, what aspects are popular, what aspects need to be improved, etc. It's all very useful information. Put a poll on your homepage...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template