Visualizzazione dei risultati da 1 a 8 su 8

Discussione: Voto unico

  1. #1
    Utente di HTML.it
    Registrato dal
    Nov 2007
    Messaggi
    274

    Voto unico

    Salve a tutti,
    andando alla ricerca di un sondaggio con voto unico, senza registrazione, ho trovato uno script che registra l'ip nel db ed impedisce un secondo voto... finché non si ha un nuovo ip

    A questo punto vorrei integrare un scrittura/controllo cookies, ma non so come fare e dove mettere le mani.

    Come fare?

    codice:
    <%
    '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") %>">
    
    
    Quali basi inedite vuoi contribuire a realizzare?
    
    <input type="radio" value="1" name="u_input">A
    
    <input type="radio" value="2" name="u_input">B
    
    <input type="radio" value="3" name="u_input">C
    
    <input type="radio" value="4" name="u_input">D
    
    <input type="radio" value="5" name="u_input">E
    
    <input type="radio" value="6" name="u_input">F
    
    <input type="radio" value="7" name="u_input">G
    
    <input type="radio" value="8" name="u_input">H
    
    <input type="submit" value="Vota" ></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
    accessdb="votes_db" 
    cn="driver={Microsoft Access Driver (*.mdb)};"
    cn=cn & "dbq=" & server.mappath("/mdb-database/votes_db.mdb")
    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, sum(selection5) AS sum_selection5, "
    sql= sql & "sum(selection6) AS sum_selection6, sum(selection7) AS sum_selection7, "
    sql= sql & "sum(selection4) AS sum_selection8, 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")
    total5=rs ("sum_selection5")
    total6=rs ("sum_selection6")
    total7=rs ("sum_selection7")
    total8=rs ("sum_selection8")
    count=rs ("total_votes")
    %>
    
    
    A[img]images/red.jpg[/img]">
    <%= formatnumber((total1/count)*100,1)  %>%
    
    B[img]images/yellow.jpg[/img]">
    <%= formatnumber((total2/count)*100,1)  %>%
    
    C[img]images/green.jpg[/img]">
    <%= formatnumber((total3/count)*100,1)  %>%
    
    D[img]images/blue.jpg[/img]">
    <%= formatnumber((total4/count)*100,1)  %>%
    
    E[img]images/blue.jpg[/img]">
    <%= formatnumber((total5/count)*100,1)  %>%
    
    F[img]images/blue.jpg[/img]">
    <%= formatnumber((total6/count)*100,1)  %>%
    
    G[img]images/blue.jpg[/img]">
    <%= formatnumber((total7/count)*100,1)  %>%
    
    H[img]images/blue.jpg[/img]">
    <%= formatnumber((total8/count)*100,1)  %>%
    
    Total Votes: <%= formatnumber(count,0,0) %>
    
     
    <% if been_here_before <> "No" then %>
    Hai già votato, questo voto non è stato conteggiato
    <% else %>
    Voto valido
    <% end if %>
    
    
    <% end if %>

  2. #2
    Utente di HTML.it
    Registrato dal
    Nov 2007
    Messaggi
    274
    Alternativamente ho anche un db con indirizzo mail e controllo validazione email

    Si potrebbe integrare?

  3. #3
    Utente di HTML.it
    Registrato dal
    Nov 2007
    Messaggi
    274
    Se non fosse troppo complicato sarebbe interessante integrare il database con le mail e far votare solo quelli che hanno "confermato" la mail, con la possibilità di votare una sola volta.

  4. #4
    stai cercando un'anima pia che ti faccia il programma o hai una domanda in particolare?

    se cerchi l'anima pia.. bhè è difficile che la troverai

  5. #5
    Utente di HTML.it
    Registrato dal
    Nov 2007
    Messaggi
    274
    se c'è, cerco un anima pia chi mi sappia indirizzare, anche un link guida, all'implementazione del controllo cookies nello script sopra.
    Per chi sa programmare in ASP dovrebbe essere facilissimo, per me invece è una cosa ai limiti dell'immaginazione.

    gli altri due post sono a puro scopo informativo e di richiesta consigli.

  6. #6

  7. #7
    Utente di HTML.it
    Registrato dal
    Nov 2007
    Messaggi
    274
    intanto grazie mille.

    Poi per integrarlo come faccio?

  8. #8
    Originariamente inviato da Okocha
    intanto grazie mille.

    Poi per integrarlo come faccio?
    invece di fare questo controllo
    codice:
    <% if been_here_before <> "No" then %>
    Hai già votato, questo voto non è stato conteggiato
    <% else %>
    Voto valido
    <% end if %>
    fallo sul coockie,
    se il cookie esiste allora ha gia votato
    altrimenti indichi il "voto valido" e crei il cookie così da non far votare più


    se vuoi farlo con le email è più sicuro che l'utente on voti 2 volte ma devi fare il controllo sull'email e non sul coockie

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.