[ASP] Poll Probleem

Pagina: 1
Acties:
  • 39 views sinds 30-01-2008

  • Denga
  • Registratie: September 2000
  • Laatst online: 14-06 16:53

Denga

The riding never stops....

Topicstarter
ik zal het nogmaals proberen aangezien ik hier al heel lang op zit te klooien en 'm maar niet aan de praat krijg, dus loop ik tegen een concreet probleem aan... Het lukt me niet om de IP wel op te laten slaan maar niet te laten controleren, zodat een IP wel meerdere malen kan stemmen.

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") %>">
<p>Wat vond je van het laatste schoolfeest?<br>
<input type="radio" value="1" name="u_input" checked >Super<br>
<input type="radio" value="2" name="u_input">geinig<br>
<input type="radio" value="3" name="u_input">niks<br>
<input type="radio" value="4" name="u_input">niet geweest<br>
<input type="submit" value="Stem" ></p>
</form>
<%
else
' if the user did input a choice on the vote/ballot
' check to see if their ip address is already in the db
' if the directory your .asp page is in does not have user
' write authority the accessdb variable and access db may
' need to be moved to your /cgi-bin/ directory and add that to the code below
accessdb="db/poll"
cn="driver={Microsoft Access Driver (*.mdb)};"
cn=cn & "dbq=" & server.mappath(accessdb)
set rs = server.createobject("ADODB.Recordset")
sql = "select ip from uitslag 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 uitslag (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 "
sql= sql & "sum(selection1) as sum_selection1, "
sql= sql & "sum(selection2) as sum_selection2, "
sql= sql & "sum(selection3) as sum_selection3, "
sql= sql & "sum(selection4) as sum_selection4, "
sql= sql & "count(*D AS total_votes "
sql= sql & "FROM uitslag;"
rs.Open sql, cn

total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
total3=rs ("sum_selection3")
total4=rs ("sum_selection4")
count=rs ("total_votes") %>

jhhjj<br>
[img]"blue.jpg"[/img]">
<%= formatnumber((total1/count)*100,1) %>%<br> super <br>
[img]"blue.jpg"[/img]">
<%= formatnumber((total2/count)*100,1) %>%<br> geinig <br>
[img]"blue.jpg"[/img]">
<%= formatnumber((total3/count)*100,1) %>%<br> niks <br>
[img]"blue.jpg"[/img]">
<%= formatnumber((total4/count)*100,1) %>%<br> niet geweest <br>
Totaal aantal stemmen: <%= formatnumber(count,0,0) %><br> <% end if %>

Never eat yellow snow...


  • raptorix
  • Registratie: Februari 2000
  • Laatst online: 17-02-2022
Toch niet moeilijk? Voor de insert doe je een select of dat IP al voorkomt, komt ie niet voor dan doe je de insert, komt ie wel voor dan geef je een melding en doe je geen insert.

  • Denga
  • Registratie: September 2000
  • Laatst online: 14-06 16:53

Denga

The riding never stops....

Topicstarter
ja en dat wil ik dus niet... iedere ip moet gewoon ingevuld worden. want 1 ip mag wel meerdere keren stemmen want het is voor een site van een school dus dat wil zeggen als iedere computer 1 keer is geweest hij niet meer stemmen van die school wil aannemen ondanks dat het wel van andere mensen is... dus vandaar hij moet het ip wel invoeren in de db maar niet controleren

Never eat yellow snow...


  • raptorix
  • Registratie: Februari 2000
  • Laatst online: 17-02-2022
Enigste manier hoe je het dan kan doen is een gebruiker zich laten registreren.

  • mbravenboer
  • Registratie: Januari 2000
  • Laatst online: 06-11-2025
De redenatie in je eerdere topic ( [topic=409769] ) lijkt mij meer dan duidelijk. P&W is niet bedoeld om mensen met weinig ASP en database ervaring te helpen om bestaande scripts aan te passen.

Als je het hier niet mee eens bent kan je een topic openen in Lieve Adjes. Probeer het aub niet steeds opnieuw.

Blog, Stratego/XT: Program Transformation, SDF: Syntax Definition, Nix: Software Deployment


Dit topic is gesloten.