建设一个简单交互的网站(五)
8. 投票系统
在许多时候,我们需要收集上网者和网友们的意见。例如:新版页面与旧版页面的比较;对某一事情的看法;对体育比赛结果的预测等等。这时候,你需要一个非常有效的网上调查系统。
8.1 投票系统(mypolls.php3):
-
<?
-
$status=0;
-
if(isset($polled)&&($polled=="c-e")){
-
$status=1;
-
}
-
#echo "$status";
-
if(isset($poll)&&($status==0)){
-
setcookie("polled","c-e",time() 86400,"/");#time=24h
-
}
-
?>
-
<html>
-
<head>
-
<title>新版页面调查</title>
-
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
-
<style type="text/css">
-
<!--
-
.tb { border="1" bordercolor="#009933" cellspacing="0" font-size: 9pt; color: #000000}
-
.head { font-family: "宋体"; font-size: 12pt; font-weight: bold; color: #009933; text-decoration: none}
-
.pt9 { font-size: 9pt}
-
a.p9:link { font-size: 9pt; color: #000000; text-decoration: none}
-
a.p9:visited { font-size: 9pt; color: #000000; text-decoration: none }
-
a.p9:hover { font-size: 9pt; color: #FF0000; text-decoration: underline}
-
a.p9:active { font-size: 9pt; color: #FF0000; text-decoration: underline }
-
-->
-
</style>
-
</head>
-
<body bgcolor="#FFFFFF">
-
<div class="head">与旧版页面相比较您觉得新版页面:</div><br>
-
<?
-
if(!isset($submit)){
-
?>
-
<form action="myPolls.php3" method="get">
-
<input type="radio" name="poll_voteNr" value="1" checked >
-
<span class="pt9">信息量更大</span> <br>
-
<input type="radio" name="poll_voteNr" value="2" >
-
<span class="pt9">网页更精美</span> <br>
-
<input type="radio" name="poll_voteNr" value="3" >
-
<span class="pt9">没什么改进</span> <br>
-
<input type="radio" name="poll_voteNr" value="4" >
-
<span class="pt9">其它</span> <br>
-
<input type="submit" name="submit" value="OK">
-
<input type="hidden" name="poll" value="vote">
-
<A HREF="myPolls.php3?submit=OK" class="p9">查看调查结果</A>
-
</form>
-
<?
-
-
-
-
}else{
-
$descArray=array(1=>"信息量更大",
-
2=>"网页更精美",
-
3=>"没什么改进",
-
4=>"其它"
-
);
-
$poll_resultBarHeight = 9;
-
$poll_resultBarScale = 1;
-