RSS
热门关键字:  下载  cms  模版  开源  dedecms
当前位置 :| 主页 > 站长学院 > PHP教程 >

简易投票系统 php+文本

来源:Blog.ChinaUnix.net 作者:未知 时间:2006-09-14 Tag: 点击:

资料来源 中文PHP俱乐部, 原创作者:ypt7497,

修改者:scudetto, 原文有图形,本文略

文件1投票页面(用radio表单,略)

你最喜欢的球队?巴西,阿根廷,意大利 ? 请选择

文件2统计 vote.php

function vote($s)

{

$F="vote.txt";

if (!file_exists($F))

{

$O=fopen($F,'w+');

$string=sprintf("%d\n%d\n%d\n%d\n",0,0,0,0);

fwrite($O, $string);

}

 

$O=fopen($F, 'r+');

for($i=0;$i<=3;$i++)

{

$s=$_POST["s"];

$V=fscanf($O,"%d\n");

list($vote[$i])=$V;

if($i==$s)

{

$vote[$i]++;

}

}

$vote[0]++;

$string="";

rewind($O);

for($i=0;$i<=3;$i++)

{$string=$string.sprintf("%d\n", $vote[$i]);}

fwrite($O, $string);

return($vote);

}

 

$vote=vote($s);

echo "总投票人数".$vote[0]."
";

echo "巴西".$vote[1]."< br >";

echo "阿根廷".$vote[2]."< br >";

echo "意大利".$vote[3]."< br >";

?>

 

文件3计数文本

touch vote.txt; chmod 777 vote.txt


最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册