注册 登录
编程论坛 ASP技术论坛

如何在asp投票中多加一个学号和密码验证功能

a920696629 发布于 2010-10-26 10:40, 709 次点击
我正在做一个学校的投票系统,现在投票系统中只有判断验证码是否正确,但是我想加判断输入的学号和密码是否跟mdb中users表中的num和password相对应
首页页面部分截图:
[img=http://www.][/img]
请问要在下面哪里加什么代码,谢谢
首页代码:
程序代码:
<!--#include file="Config/Conn.asp" -->
<!--#include file="Include/Class_Function.asp" -->

<%
Rem 判断验证码输入是否正确的函数
Function ValidCode(pSN,k,c)
   
Dim s,i
    s
= Session(pSN)
    k
= ";"&k&":"
    ValidCode
= False
    i
= InStr(s,k)
   
If i > 0 Then
        
If InStr(s,k&c&";") > 0 Then ValidCode = True
        Session(pSN)
= Left(s,i) & Right(s,Len(s)-InStr(i+1,s,";"))
   
End If
End Function

Dim codeKey
codeKey
= Int(Timer()*10)
%>

<%
   
if Request("action")="Save" then
        ckbox
=Request("ckbox")
        B
=split(ckbox,",")
        
if ValidCode("CSName",Request.Form("codeKey"),Request.Form("code")) then
            UserIP
=GetUserIP()
            
Set Rsas=Server.CreateObject("Adodb.RecordSet")
            Sqlas
= "Select * From UserIP where UserIP='"&UserIP&"'"
            Rsas.Open Sqlas,Conn,
1,1
            
if not (Rsas.Eof or Rsas.Bof) then
            twscript(
"你已参加过投票,每人只能投票一次")
            
else
            
Set Rsip=Server.CreateObject("Adodb.RecordSet")
            Sqlip
= "Select * From UserIP"
            Rsip.Open Sqlip,Conn,
1,3
            Rsip.Addnew
            Rsip(
"UserIP")=UserIP
            Rsip(
"PostTime")=now()
            Rsip.Update
            Rsip.Close
            
Set Rsip=Nothing
            
end if
            Rsas.Close
            
Set Rsas=Nothing
           
            
Set Rsa=Server.CreateObject("Adodb.RecordSet")
            Sqla
="Select * From NewsInfo"
            Rsa.Open Sqla,Conn,
1,1
            
do while not Rsa.Eof
            
for i=lbound(B) to ubound(B)
            
if cint(Rsa("ID"))=cint(B(i)) then
               
Set Rs=Server.CreateObject("Adodb.RecordSet")
                Sql
= "Select * From NewsInfo Where ID="&Rsa("ID")&""
                Rs.Open Sql,Conn,
1,3
                Rs(
"Click")=Rs("Click")+1
                Rs.Update
                Rs.Close
               
Set Rs=Nothing
            
end if
            
next
            Rsa.MoveNext
            
Loop
            Rsa.Close
            
Set Rsa=Nothing
        
else
            Response.Write(
"<script>alert('输入的验证码错误!'); history.go(-1);</script>")
            Response.end()
        
end if
        Response.Write(
"<script>alert('评选成功');top.window.location.href='result.asp';</script>")
   
end if
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.>
<html xmlns="http://www.>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<%=SiteKeysTitle("")%>
<link href="css/css.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="967" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" valign="top" bgcolor="#990f00" class="p_10">
    <table width="947" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td align="center" valign="top" bgcolor="#FFFFFF" class="p_5"><table width="937" border="0" cellspacing="0" cellpadding="0" class="b_ffd87d">
            <tr>
              <td width="611" align="center" valign="top" bgcolor="#FFFFFF">
              <table width="611" border="0" cellpadding="0" cellspacing="0">
                <tr>
            <%
               
Set Rs=Server.CreateObject("Adodb.RecordSet")
                Sql
="Select * From NewsInfo where ClassID=1 Order By PostTime Desc,NewsOrder Desc"
                Rs.Open Sql,Conn,
1,1
                Page
=ReplaceBadChar(Trim(Request("Page")))            
                PageSize
=99   
                Rs.PageSize
= PageSize              
                Total
=Rs.RecordCount              
                PGNum
=Rs.PageCount              
               
If GetSafeInt(Page) > PGNum Then Page=PGNum              
               
If PGNum>0 Then Rs.AbsolutePage=Page
                i
=0
               
Do While Not Rs.Eof And i<Rs.PageSize
            
%>
            <% if i=3 or i=4 or i=5 or i=9 or i=10 or i=11 or i=15 or i=16 or i=17 or i=21 or i=22 or i=23 then%>
            <td align="center" bgcolor="#fff2cf">
            <% else %>
            <td align="center">
            <% end if %>
            <table width="180" border="0" cellpadding="0" cellspacing="0" class="m_15">
            <tr>
            <td width="20" height="34" align="center" valign="middle"><img src="images/index_01.jpg" width="7" height="13" /></td>
            <td width="160" align="left" valign="middle"><a href="shownews.asp?ID=<%=Rs("ID")%>" target="_blank" class="l1" title="<%=Rs("NewsTitle")%>"><%=GetNewsTitle(Rs("ID"),18)%></a></td>
            </tr>
            <tr>
            <td colspan="2" align="center" valign="middle"><a href="shownews.asp?ID=<%=Rs("ID")%>" title="<%=Rs("NewsTitle")%>" target="_blank"><img src="<%=Rs("NewsSPic")%>" width="130" height="100" /></a></td>
            </tr>
            <tr>
            <td colspan="2" align="left" valign="top"><%=distill(Rs("NewsContent"),54)&"..."%></td>
            </tr>
            </table>
            </td>
            <%
                i
=i+1
               
If i mod 3=0 Then
                Response.Write(
"</tr><tr>")
               
End If
                rs.MoveNext
               
loop
                Rs.Close
               
Set Rs=Nothing
            
%>
                </tr>
              </table></td>
              <td width="324" align="center" valign="top" bgcolor="#FFFFFF">
              <table width="313" border="0" cellspacing="0" cellpadding="0" class="m_t_15">
                <tr>
                  <td align="left" class="f_b f_000"><img src="images/top_03.jpg" width="9" height="9" style="margin:0 3px;" />你心目中的十大新闻</td>
                  </tr>
                <tr>
                  <td align="left" valign="top" class="f_db0d02"><strong>投票规则</strong><br />
请您做出选择参与投票。在“你心目中的2校园十大新闻”栏中打勾,每次投票至少选择十条新闻,最多不限。</td>
                  </tr>
              </table>
              <form name="formnews" method="post">
              <table width="313" border="0" cellspacing="0" cellpadding="0">
                  <%
                    
Set Rs=Server.CreateObject("Adodb.RecordSet")
                    Sql
= "Select * From NewsInfo where ClassID=1 Order By PostTime Desc,NewsOrder Desc"
                    Rs.Open Sql,Conn,
1,1
                    i
=1
                    
do while not Rs.Eof
               
%>
                <tr>
                  <td width="24" align="center" valign="top"><input type="checkbox" name="ckbox" id="checkbox" value="<%=Rs("ID")%>" /></td>
                  <td width="289" align="left" valign="top"><%=i%><%=Rs("NewsTitle")%></td>
                </tr>
                <%
                    i
=i+1
                    Rs.MoveNext
                    
Loop
                    Rs.Close
                    
Set Rs=Nothing
               
%>
              </table>
              <table width="313" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td align="left" valign="top"><p>&nbsp;</p>
                  <div id="seccodeimage" class="dis_n"><img src="DvCode.asp?k=<%=codeKey%>&" onclick="this.src+=parseInt(Math.random()*10)" alt="看不清楚?点击换一张" style="cursor:pointer;"></div>                 
                  <p>请输入验证码
                    <input type="hidden" name="codeKey" value="<%=codeKey%>">
                    <input name="code" type="text" class="ipt" id="textfield" onfocus="updateencode();;this.onfocus = null" />
                    点击输入框显示验证码! 如果看不清验证码,请点图片刷新! </p></td>
                  </tr>
                <tr>
                  <td align="center"><input type="button" name="button" id="button" value="" style="background:url(images/index_02.jpg) no-repeat; width:68px; height:20px; border:0; cursor:pointer;" onclick="anyCheck(this.form)"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset" name="button2" id="button2" value="" style="background:url(images/index_03.jpg) no-repeat; width:68px; height:20px; border:0; cursor:pointer;" onclick="location.href='result.asp'" /></td>
                  </tr>
              </table>
              </form>              <script language="javascript">
                  
function updateencode()
                  {
                    
var onOption = document.getElementById("seccodeimage");
                    onOption.className
="dis_b";
                  }
                  
function anyCheck(form) {
                    
var total = 0;
                    
var max = form.ckbox.length;
                    
for (var idx = 0; idx < max; idx++) {
                    
if (eval("document.formnews.ckbox[" + idx + "].checked") == true) {
                        total
+= 1;
                       }
                    }
                    
if (total<10){
                        alert(
"你选择了 " + total + " 个选项。未满足要求");
                        
return false;
                        }
                    document.formnews.action
="?action=Save";
                    document.formnews.submit();
                    }
                    

              
</script>
              <table width="313" border="0" cellspacing="0" cellpadding="0" class="m_15">
                <tr>
                  <td align="left" valign="top" class="f_db0d02">&nbsp;</td>
                </tr>
              </table>
              </td>
            </tr>
          </table>
          </td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>



 

[ 本帖最后由 a920696629 于 2010-10-26 10:41 编辑 ]
5 回复
#2
a9206966292010-10-26 10:58
希望能帮我解决下,谢谢!
#3
a9206966292010-10-26 11:04
希望能帮我解决下,谢谢!
#4
a9206966292010-10-26 12:05
希望能帮我解决下,谢谢!
#5
hams2010-10-26 13:04
先去学一下判断语句和读数据库的代码。
#6
dzt00012010-10-26 13:07
只能提供一个思路,代码要你自己去写的
如果要用户名和密码来登录,就可以不用限制同一IP重复投票了
可以先做登录页面,登录后才能进入投票页面,保存投票时判断这个用户名是否已投票,如没有,则记录投票内容、用户名等
也可以在你那个投票页面加入用户名和密码文本框,提交后先对用户名和密码做判断,再判断是否投过票,没有投票的则记录投票内容

登录判断应该很简单的
 
1