vote.asp
来自「修正的自由领域投票系统2.0 支持文件上传」· ASP 代码 · 共 94 行
ASP
94 行
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="const.asp"-->
<!--#include file="conn.asp"-->
<% if request.Cookies("tfot_tp")("sid")="" then
response.Write(escape("您还没有登录"))
response.End()
end if
dim id,vote0
id=trim(request.Form("toupiao"))
if id="" Then
response.Write("")
response.End()
end if
'------获取学生数据开始
dim sid,vote1,num
sid=request.Cookies("tfot_tp")("sid")
set rs=conn.execute("select * from ec where sid='"&sid&"'")
vote1=rs("vote")
vote0=vote1
num=rs("num")
set rs=nothing
'------获取结束--------
id=Replace(id," ","")
vote1=replace(vote1," ","")
vote1=replace(vote1,"dxf,","")
if instr(vote1,",")>0 then
vote1=split(vote1,",")
end if
dxf=true
wo=false
if isarray(vote1) then
for j=0 to ubound(vote1)
if id=vote1(j) then
dxf=false
wo=true
exit for
end if
next
else
if id=vote1 then
dxf=false
wo=true
end if
end if
if dxf=true then
if (num+1)>maxvote then
response.Write(escape("您已经不能再投票了"))
response.End()
end if
conn.execute("update stu set vote=vote+1 where id="&id)
conn.execute("update ec set num=num+1 where sid='"&sid&"'")
vote0=vote0+","+id
vote0=replace(vote0,"dxf,,","")
conn.execute("update ec set vote='"&vote0&"' where sid='"&sid&"'")
end if
if wo=true then
set rs=conn.execute("select * from ec where sid='"&sid&"'")
dim voteid
voteid=rs("vote")
set rs=nothing
vote2="dxf,"
voteid=replace(voteid,"dxf,","")
if instr(voteid,",")>0 then
voteid=split(voteid,",")
end if
if isarray(voteid) then
for i=0 to ubound(voteid)
if voteid(i)<>id then
vote2=vote2+","+voteid(i)
end if
next
vote2=replace(vote2,"dxf,,","")
conn.execute("update ec set vote='"&vote2&"' where sid='"&sid&"'")
conn.execute("update ec set num=num-1 where sid='"&sid&"'")
conn.execute("update stu set vote=vote-1 where id="&id)
response.Write(escape("恭喜!撤销投票成功"))
cxcg=1
else
if voteid=id then
conn.execute("update ec set vote='"&vote2&"' where sid='"&sid&"'")
conn.execute("update ec set num=num-1 where sid='"&sid&"'")
conn.execute("update stu set vote=vote-1 where id="&id)
end if
response.Write(escape("恭喜!撤销投票成功"))
cxcg=1
end if
end if
if cxcg<>1 then response.Write(escape("恭喜!投票成功"))
set conn=nothing
%>
<body>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?