ENQUETE DUPLICANDO RESULTADO

WEBIER 30/10/2009 12:38:27
#326586
Amigos,

catei na net uma Enquete em ASP e fiz algumas modificações nela...

Tanto antes como depois das modificações notei q quando alguem votar em algumas das opções ela duplica o voto...

exemplo:

Opção1 = 10 votos

escolha a opção1 e do um clique no botão votar...

Opção1 = 12 votos

ele sempre pega meu voto e soma com + 1

olha o codigo completo ai a baixo:

<% 
Dim ADOCnn
Dim rsEnquete

%>
<link href=[Ô]../estilos.css[Ô] rel=[Ô]stylesheet[Ô] type=[Ô]text/css[Ô]>
<%

Set ADOCnn = Server.CreateObject([Ô]ADODB.Connection[Ô])
Set rsEnquete = Server.CreateObject([Ô]ADODB.Recordset[Ô])

ADOCnn.Open([Ô]Provider=Microsoft.Jet.OLEDB.4.0; Data Source=[Ô]& Server.MapPath([Ô]\enquete\dados.mdb[Ô]))
ADOCnn.CursorLocation = 3

if Request.form([Ô]votar[Ô]) = [Ô][Ô] and Request.form([Ô]resultado[Ô]) = [Ô][Ô] and Request.QueryString([Ô]resultado[Ô]) = [Ô][Ô] then

Set rsEnquete = ADOCnn.Execute([Ô]select * from tab_enquete where ativa = true order by codigo desc[Ô])
if rsEnquete.RecordCount > 0 then
%>
<form name=[Ô]frmVotar[Ô] method=[Ô]post[Ô] action=[Ô][Ô]>
<table width=[Ô]230px[Ô]cellpadding=[Ô]0[Ô] cellspacing=[Ô]0[Ô] height=[Ô]41[Ô]>
<tr>
<td width=[Ô]230[Ô]>
<font face=[Ô]Arial[Ô] size=[Ô]2[Ô] color=[Ô]black[Ô]><strong><%= rsEnquete([Ô]enquete[Ô]) %></strong></font><br><br>
</td>
</tr>
<input type=[Ô]hidden[Ô] style=[Ô]display:none[Ô] name=[Ô]codigo[Ô] value=[Ô]<%= rsEnquete([Ô]codigo[Ô]) %>[Ô]>
<%
for i = 1 to 5
if rsEnquete([Ô]op_[Ô]& i) <> [Ô][Ô] then
%>
<tr>
<td width=[Ô]230[Ô]>
<font face=[Ô]Arial[Ô] size=[Ô]2[Ô] color=[Ô]black[Ô]>
<input type=[Ô]radio[Ô] name=[Ô]op[Ô] value=[Ô]re_<%= i %>[Ô] <% if i = 1 then response.write([Ô]unchecked[Ô]) %> ><%= rsEnquete([Ô]op_[Ô] & i) %>
</td>
</tr>
<%
end if
next
%>
<tr>
<td colspan=[Ô]2[Ô] align=[Ô]center[Ô] valign=[Ô]bottom[Ô] width=[Ô]230[Ô]>
<input type=[Ô]hidden[Ô] style=[Ô]display:none[Ô] name=[Ô]votar[Ô] value=[Ô][Ô]>
<br><input type=[Ô]image[Ô] src=[Ô]btn_votar.gif[Ô] onClick=[Ô]document.frmVotar.votar.value=[ô]ok[ô];document.frmVotar.submit();[Ô] align=[Ô]center[Ô]><!--<input type=[Ô]submit[Ô] name=[Ô]resultado[Ô] value=[Ô]Ver resultados[Ô] class=[Ô]command[Ô]>-->
</td>
</tr>

</table>
</form>

<%
end if
elseif Request.form([Ô]votar[Ô]) <> [Ô][Ô] and Request.QueryString([Ô]resultado[Ô]) = [Ô][Ô] then

Set ADOCnn = Server.CreateObject([Ô]ADODB.Connection[Ô])
Set rsEnquete = Server.CreateObject([Ô]ADODB.Recordset[Ô])

ADOCnn.Open([Ô]Provider=Microsoft.Jet.OLEDB.4.0; Data Source=[Ô]& Server.MapPath([Ô]\enquete\dados.mdb[Ô]))
ADOCnn.CursorLocation = 3

codigo = Request.Form([Ô]codigo[Ô])
op = Request.Form([Ô]op[Ô])

Set rsEnquete = ADOCnn.Execute([Ô]update TAB_ENQUETE set [Ô] & op & [Ô] = [Ô] & op & [Ô] + 1 where codigo = [Ô] & codigo )

if Err.number > 0 then
response.write([Ô]<center>Ocorreu um erro ao tentar votar na enquete !!</center>[Ô])
else
response.write([Ô]<center>O seu voto foi recebido com sucesso !!</center>[Ô])
response.write([Ô]<meta http-equiv=[Ô] & chr(34) & [Ô]refresh[Ô] & chr(34) & [Ô] content=[Ô] & chr(34) & [Ô]1.5;URL=[ô]votarEnquete.asp?resultado=true&c=[Ô] & codigo & [Ô][ô][Ô] & chr(34) & [Ô]>[Ô])
end if

else

Set ADOCnn = Server.CreateObject([Ô]ADODB.Connection[Ô])
Set rsEnquete = Server.CreateObject([Ô]ADODB.Recordset[Ô])

ADOCnn.Open([Ô]Provider=Microsoft.Jet.OLEDB.4.0; Data Source=[Ô]& Server.MapPath([Ô]\enquete\dados.mdb[Ô]))
ADOCnn.CursorLocation = 3

if Request.QueryString([Ô]resultado[Ô]) = [Ô][Ô] then
codigo = Request.Form([Ô]codigo[Ô])
else
codigo = Request.QueryString([Ô]c[Ô])
end if


Set rsEnquete = ADOCnn.Execute([Ô]select *, (re_1 + re_2 + re_3 + re_4 + re_5) as total from tab_enquete where codigo = [Ô] & codigo )

%>

<table cellpadding=[Ô]0[Ô] cellspacing=[Ô]0[Ô]>
<tr>
<td colspan=[Ô]2[Ô]>
<strong><%= rsEnquete([Ô]enquete[Ô]) %></strong>
</td>
</tr>

<%
for i = 1 to 5
if rsEnquete([Ô]op_[Ô]& i) <> [Ô][Ô] then
%>
<tr>
<td>
<%= rsEnquete([Ô]op_[Ô] & i) %>
</td>
<td align=[Ô]left[Ô]>
<hr style=[Ô]height:10px;color:#000066;width:<%= (cint(rsEnquete([Ô]re_[Ô] & i) / cint(rsEnquete([Ô]total[Ô])) * 100)) %>[Ô]>
</td>
<td width=[Ô]10%[Ô]>
<%= rsEnquete([Ô]re_[Ô] & i) %>
</td>
</tr>
<%
end if
next
%>
<tr>
<td colspan=2> <font size=[Ô]2[Ô] face=[Ô]Arial, Helvetica, sans-serif[Ô]><strong>Total
de votos</strong></font> <strong><font color=[Ô]#FF0000[Ô]><%= rsEnquete([Ô]total[Ô]) %></font></strong> </td>
</table>
<%
end if
%>


JUNIORNET 30/10/2009 13:27:55
#326594
Resposta escolhida
Kra manda o link de onde voce baixou para eu ver funcionando

Junior.
WEBIER 30/10/2009 15:51:36
#326606
faz uns 400 anos...

nem sei mais onde foi!
WEBIER 30/10/2009 15:53:28
#326607
olha esse site ai q tah usando a enquete q eu fiz... faz o teste


www.vitoriaeventos.com.br
Tópico encerrado , respostas não são mais permitidas