Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool Do While Not rs.EOF (easy for you guys, hard for me)

    I would never usually ask but im sooo stumped you would not belive!!!

    im trying to run a vote with a 24 hour time limit/ date between voting. (ive done it with cookies in the past but people have just started clearing their cookies)

    the idea is the page reads the ip address from the url:
    /inc_voting.asp?IPDATE=24%2F10%2F2005&IPCHECK=***.**.**.**

    then checks to see if the IP address is currently in the DB (if not it will allow you to vote). if it finds your ip in the DB it then checks to see if the dates match (if it does match it sends you to you cant vote page) if the dates dont match then it allows you to vote again.

    Code:
    <%
    Session.LCID = 2057
    
    Set Connect = Server.CreateObject("ADODB.Connection")
    Connect.Open MM_connDUpoll_STRING
    Query = "Select * from tbl_check WHERE IPCHECK='"&Request("IPCHECK")&"'"
    Set rs=Connect.Execute(Query)
    
    If rs.EOF then
    Response.Redirect("YOU CAN VOTE PAGE")
    
    Else
    
    Do While Not rs.EOF
    
    If FormatDateTime(Request("IPDATE"))=FormatDateTime(rs("IPDATE")) then
    
    Response.Redirect("SORRY YOU CANT VOTE PAGE")
    Else
    Response.Redirect("YOU CAN VOTE PAGE")
    End If
    
    rs.MoveNext
    Loop
    End If
    
    rs.Close
    Connect.Close
    %>
    the problem is its only reading the first ip address and not reading all the way through checking each ip entry against the date.

    i cant see what ive done wrong and any help would be greatly appreciated.

    Regards

    Charlie

  • #2
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    First off, you don't want to loop through all the IP addresses, you only want to loop through the list of IP addresses that are the same.
    Your problem has to do with redirecting. You'll check the first IP and if it's wrong, you'll leave the loop.

    Code:
    Do While Not rs.EOF
      If FormatDateTime(Request("IPDATE")) <> FormatDateTime(rs("IPDATE")) Then
        Response.Redirect("YOU CAN VOTE PAGE")
      End If
      rs.MoveNext
    Loop
    If this isn't the problem, please check to see what information you actually are pulling out of your database.

  • #3
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ta for your help,

    what i have done is set it to check to see if the ip is in the db then if it is check the date, if the date is not a match it will let you vote but updates the ip address it just checked with todays date.... hence only storing 1 of each ip address not every ip address entered.... if you catch my drift

    ta for your help

    Charlie

  • #4
    Senior Coder Morgoth's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada Remaining Brain Cells: 6
    Posts
    1,402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Good idea. You should also a vote counter too. You might not need it now, but it might be neat for the future. You can also check to see if someone beat the system at one point, and maybe fix any glitches you never knew about.

    So you store the user's IP, vote date (lastest vote), and how many times they voted.
    You can add lots of things too, like what they voted for, or go into extreme detail and keep complete records on each and every user's IP that enters your site, see what they did.

    Enjoy.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •