- 爱易网页
 
                        - 
                            ASP教程
 
                        - 一个投票过程的日志记录顺序怎么修改 
 
                         
                    
                    
                    日期:2014-05-17  浏览次数:21138 次 
                    
                        
                         求助一个投票过程的日志记录顺序如何修改?
判断投票时有的项目的选项没有选择就跳回投票页面,但是刚投的空票却将投票的iP和时间记录到数据库里面了。要如何才能先判断再记录呢? 
  
 代码如下: 
  
  <%option   explicit%>  
  <%response.expires   =   0%>  
  <!--#include   file= "common/conn.asp "-->  
  
  
  <% 
  '验证投票日期是否有效 
  'startTime   所指那天为投票开始的第一天 
  'endTime   所指那天为投票结束的第一天 
  'endTimeValid   结束时间是否有效 
  '投票还没开始返回   1 
  '投票已经结束返回   -1 
  '投票时间有效返回   0 
 function   ValidVoteDate(startTime,   endTime,   endTimeValid) 
             if   DateDiff( "d ",   startTime,   Date())    <   0   then 
                         ValidVoteDate   =   1 
             elseif   endTimeValid   and   DateDiff( "d ",   Date(),   endTime)    <=   0   then 
                         ValidVoteDate   =   -1 
             else 
                         ValidVoteDate   =   0 
             end   if 
 end   function 
  
  '验证投票间隔是否有效 
 function   ValidVoteInterval(conn,   rs,   subjectID,   clientIP,   intervalValue,   intervalUnit) 
             dim   sql 
             sql   =    "select   top   1   logTime   from   voteLogs   where   subjectID= "   &   CLng(subjectID)   &    "   and   clientIP= ' "   &   Replace(clientIP, " ' ", " ' ' ")   &    " '   order   by   logID   desc " 
             rs.Open   sql,   conn,   1,   1 
             if   not   rs.eof   then 
                         if   DateDiff(intervalUnit,   rs( "logTime "),   Now())   >    intervalValue   then 
                                     ValidVoteInterval   =   true 
                         else 
                                     ValidVoteInterval   =   false 
                         end   if 
             else 
                          '记录不存在,些   IP   还没有针对本主题进行过投票 
                         ValidVoteInterval   =   true 
             end   if 
             rs.Close 
 end   function 
  
  
  '为一项投票 
  '仅被   UpdateOptions   调用 
 function   UpdateOption(conn,   itemID,   validOptionsCnt) 
             dim   votedOptionsCnt 
             votedOptionsCnt   =   request.Form( "option_ "&itemID).count 
             if   validOptionsCnt> 0   and   votedOptionsCnt> validOptionsCnt   then 
                          'validOptionsCnt    <=0   表示不限制选项数 
                         exit   function