目前正在使用 Bitrix CMS,需要为特定组的用户投票。知道组的 id 后,我制作了一个表格,里面有一堆单选按钮。当有人投票时,结果应该写在文件(或数据库)中,并在页面上写上“谢谢你的投票!” 应显示。我的问题是最好的方法是什么?
我尝试了几种不同的方法:
1)本教程,不起作用
2)另外两个网络教程,如果你问我可以链接
3)来自 bitrix 的投票表格,但是对于系统的那个模块应该改变,不建议这样做。
下面是带有投票本身的页面,但是“poll.php”让我感到困惑,因为不知道正确的方法。如此好的建议将不胜感激。
ps你可以忽略'Bitrix'部分,最重要的是php
/*get users from group in array*/
<?$arUsers = CGroup::GetGroupUser(20);
$iCountUsers = 0;
$arUsersbyGroupID = array();
foreach($arUsers as $arUser) {
$arUserbyID = CUser::GetByID($arUser);
$rsUserbyID = $arUserbyID -> Fetch();
$arUsersbyGroupID[] = $rsUserbyID; }
$iCountUsers++;?>
<div class="wrapper">
<div id="poll-container">
<form class="grid" action="poll.php" method="post" accept-charset="utf-8">
/*for each create element with radio button*/
<?$iVoteCount = 0;
$allopt = array();
foreach($arUsersbyGroupID as $Vote) {
$photo = $Vote["PERSONAL_PHOTO"];
if (!empty($photo)) {
$name = "{$Vote["NAME"]} {$Vote["LAST_NAME"]}";?>
<div class="cell">
<div class="cell_img"><?echo CFile::ShowImage($photo)?></div>
<div class="cell_caption">
<input type="radio" value="<?=$iVoteCount?>" name="vote" onclick="getVote(this.value)" />
<label for='opt<?=$iVoteCount?>'><?echo $name?></label>
</div>
</div>
$iVoteCount++;
}
} ?>
<div id="sub"><input type="submit" value="Vote" /></div>
</form>
</div>
</div>