[Resolvido] Como tirar registro de IP da Enquete e deichala livre
Ai galera tentei remover essa função mas dá erro como remover essa opção de que grava IP da pessoa. Queria que a enquete ficasse livre para
votar a votande.
<html>
<head>
<title>Enquete</title>
<script language="JavaScript" type="text/javascript">
<!--
//Definindo as variáveis:
var objRadio;
var i;
var checado = 0;
function selecionar(e) {
objRadio = document.forms["form1"].elements["u_input"];
if (e==1) {
objRadio[0].checked = true;
}
if (e==2) {
objRadio[1].checked = true;
}
}
function votar() {
objRadio = document.forms["form1"].elements["u_input"];
for (i=0; i < objRadio.length; i++) {
if (objRadio[i].checked == true) {
checado = 1;
if(confirm("Você escolheu a figura: "+(i+1)+"\nDeseja prosseguir?")) {
document.form1.submit();
}
}
}
if (checado == 0) {
alert("Por favor, selecione uma opção.");
return false;
}
}
-->
</script>
</head>
<body><%
'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 name="form1" action="<%= request.servervariables("script_name") %>" method="post">
Selecione uma opção:
<br><img src="figura1.gif" border="0" onClick="selecionar(1)"><input type="radio" name="u_input" value="1">
<br><img src="figura2.gif" border="0" onClick="selecionar(2)"><input type="radio" name="u_input" value="2">
<br><br>
<input type="button" value="Votar" onClick="votar();">
</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(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, count(*) AS total_votes "
sql= sql & "FROM ballot;"
rs.Open sql, cn
total1=rs ("sum_selection1")
total2=rs ("sum_selection2")
count=rs ("total_votes")
%><br><br><br><br><br><br>
A<img src="images/blue.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 %>
<% else %>
<% end if %>
<br>
The I.P. Address is <%= u_ip %>
<% end if %>
</body>
</html>Discussão (5)
Carregando comentários...