<%option explicit response.buffer = true%> <% 'poll survay - by Elad Rosenberg 'for comments and questions: 'eladr@tip.co.il response.buffer = true 'declaring dim conn,sql,rs,x dim useraction,ansid,sql1 dim ansdesc,newtotal,total,iTotal,t,ImageWidth dim sql_statement dim ors,rs2,ans dim final_total dim ansimage dim votetwice,already,msg,ansPercent dim queIDStr,queID,i,queIDarr dim action,sql2,rs1,us,ansTotal x = 0 'connect to db subroutine set conn=server.createobject("adodb.connection") conn.open dsn 'closing object subrotine sub close() rs.close set rs=nothing conn.close set conn=nothing end sub action = request("action") select case action case "vote" 'those lines are preventing users to vote more than once 'set votetwice to false if you want to let users free vote 'else reamain true '-------------------------------------------------------- voteTwice=false '--------------------------------------------------------- select case voteTwice case true if request.cookies("pollFlag")="" then response.cookies("pollFlag")="already" Response.Cookies("pollFlag").Expires = Date + 365 else response.redirect "poll.asp?action=view&msg=1" end if end select queIDStr = trim(request.form("queID")) 'response.write "*" & queIDStr & "*" queIDarr = split(queIDStr,",") for i=0 to ubound(queIDarr) ansID = request.form("poll"& trim(queIDarr(i)) &"") ansID = trim(ansID) set rs = server.createobject("adodb.recordset") if ansID="" then x = x + 1 else sql="select total from ans where id="&trim(ansID) rs.open sql,conn total=rs("total") total=total+1 'response.write "

" & total & "

" sql1="update ans set total="& total &" where id="&ansid 'response.write sql1 conn.execute(sql1) rs.close set rs = nothing end if next if x-1 = ubound(queIDarr) then response.write "You have to answer at least on 1 quetion - results are:
" end if %> <% 'already voted/show results case "view" msg=request("msg") if msg<>"" then response.write "You can't vote twice!

" end if %> <% conn.close set conn = nothing end select %>