..:: MX Studio Fóruns ::..: Asp não está enviando os dados ao banco (enquete) - ..:: MX Studio Fóruns ::..

Jump to content

Publicidade




ATENÇÃO

Para evitar posts desnecessários e que não influam para o andamento e desenvolvimento do fórum, clique aqui e leia todas as regras.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Asp não está enviando os dados ao banco (enquete) Asp não está enviando os dados ao banco (enquete)

#1 User is offline   Elton Miguel 

  • Group: Membros
  • Posts: 1
  • Joined: 27-January 06

Posted 26 July 2007 - 06:01 PM

Pessoal to com este código mais não consigo fazer o envio do voto para o banco de dados.... alguem sabe onde pode estar o erro??


CODE
<%
'Two varibles are passed into the db
'u_input is the value if the user entered a response to
'the vote/poll question....IP is the address of the user
u_input=request.form("u_input")
u_ip=request.servervariables("remote_addr")

' if the user did not enter anything in the poll on this visit
' then display the poll question and possible choices
if u_input = "" then
%>

<form method="post" action="<%= request.servervariables("script_name") %>">
<table width="125" border="0">
  <tr>
    <td><p>Pergunta<br />
          <input type="radio" value="1" name="u_input" />
      A<br />
          <input type="radio" value="2" name="u_input">
      B<br />
          <input name="submit" type="submit" value="Submit"></p>
      <%
else
' if the user did input a choice on the vote/ballot
' check to see if their ip address is already in the db
accessdb="votes_db.mdb"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select ip from ballot where ip ='" & u_ip & "'"

rs.Open sql, cn
if rs.eof then
' if the user has not voted previously indicate it
been_here_before="No"
end if
rs.close

if been_here_before = "No" then
' Since the user has not voted previously their input
' their vote will be added to the db

sql = "insert into ballot (ip, selection" & u_input &") "
sql = sql & "values ('" & u_ip & "',1)"
rs.Open sql, cn
end if

'This will summerize and count the records in the db
sql= "select distinctrow sum(selection1) as sum_selection1, "
sql= sql & "sum(selection2) AS sum_selection2, sum(selection3) AS sum_selection3, "
sql= sql & "sum(selection4) AS sum_selection4, count(*) AS total_votes "
sql= sql & "FROM ballot;"
rs.Open sql, cn
total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
total3=rs ("sum_selection3")
total4=rs ("sum_selection4")
count=rs ("total_votes")
%>
      <br />
A<img src="images/red.jpg" height="10" width="<%= (total1/count)*100 %>" /> <%= formatnumber((total1/count)*100,1)  %>%<br />
B<img src="images/yellow.jpg" height="10" width="<%= (total2/count)*100 %>" /> <%= formatnumber((total2/count)*100,1)  %>%<br />
Total Votes: <%= formatnumber(count,0,0) %><br />
<% if been_here_before <> "No" then %>
This user has voted before and this one was <u>not</u> counted.....
<% else %>
This user has <u>not</u> voted before and this one was counted.....
<% end if %>
<br />
The I.P. Address is <%= u_ip %>
<% end if %></td>
  </tr>
</table>
<p>&nbsp;</p>
</form>




Grato
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic



Publicidade




1 User(s) are reading this topic
0 membro(s), 1 visitante(s) e 0 membros anônimo(s)