开发者

Attendance tracker/multi vote

I want to create a multi vote, give people 3 options (yes/no/maybe) and log who voted and who did not vote. Is this easy to do in javascript ? Ideally I want to not let them see anything else on my site until they particpate in this vote, and I found code to do a one track redirect that I can modify, but I am not sure what the best way of going about the whole thing is. I am just looking for suggestions, but any code will be great too. My site does not support an SQL server at the 开发者_Python百科moment.


You can do it like this

index.php (first page when user enters your site)

session_start();
$hasVoted = $_SESSION['hasVoted'];
$vote = htmlspecialchars($_GET['vote']);

if(empty($hasVoted)){
 if(!empty($vote)){
 $_SESSION['hasVoted'] = "true";
 }
}

if($hasVoted == "true"){
header("location:home.php");
} else {
print"Please vote in next poll to access our site:";
// and here you print voting form
}

home.php

session_start();
if($_SESSION['hasVoted'] !== "true"){
header("location:index.php");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜