DDean
asked on
ip compare DB field loginIP to REMOTEadr
I have a from that a visitor completes. It saves the form in an access db with current date (date format) as dateadded and Request.ServerVariables("R EMOTE_ADDR ") as loginIP (textfield). There a a couple of field saved but the are not important at this time.
Once the visitor completes the form they can not resubmit another form until the next day. So if a visitor tries to submit a second form on the same day they are sent to a "too bad fo you you have to wait until tomorrow" page.
I query the table where the dateadded equal date() and loginIP=Request.ServerVari ables("REM OTE_ADDR") Right now I can get the new ip from the second attempt to submit another form and I can response.write both the dateadded and the loginIP but when i query it nothing happens. I have looked all over the web for a solution but i can't find a solution or a part solution I can expand on. I ahve attached the code I am having a problem with.newtest.txt
Once the visitor completes the form they can not resubmit another form until the next day. So if a visitor tries to submit a second form on the same day they are sent to a "too bad fo you you have to wait until tomorrow" page.
I query the table where the dateadded equal date() and loginIP=Request.ServerVari
ASKER
Dave,it still isn't selecting base on the where. Could it be possible may structure is wrong
there 3 fields
dateadded - type: date/time short date added as default
selection - type: text length 50
loginIP - Type: text length 15 123.456.789.012 ( the length was 14. fixed ... that still no work
here is the code that I last tried
If I don't select 'where' I can list all the fields including the calculated fields
5/7/20155/10/201564.114.22 8.241
5/7/20155/10/201564.114.22 8.241
5/4/20155/10/201564.114.22 8.241
5/3/20155/10/201564.114.22 8.241
5/2/20155/10/201564.114.22 8.241
5/8/20155/10/201564.180.17 9.174
5/10/20155/10/201564.114.2 28.241
5/8/20155/10/201564.114.22 9.185
I am beginning to feel rather stupid. In my mind the code should work
Thoughts???
there 3 fields
dateadded - type: date/time short date added as default
selection - type: text length 50
loginIP - Type: text length 15 123.456.789.012 ( the length was 14. fixed ... that still no work
here is the code that I last tried
If I don't select 'where' I can list all the fields including the calculated fields
5/7/20155/10/201564.114.22
5/7/20155/10/201564.114.22
5/4/20155/10/201564.114.22
5/3/20155/10/201564.114.22
5/2/20155/10/201564.114.22
5/8/20155/10/201564.180.17
5/10/20155/10/201564.114.2
5/8/20155/10/201564.114.22
I am beginning to feel rather stupid. In my mind the code should work
Thoughts???
ASKER
Forgot the code
newtest.txt
newtest.txt
Attached is the code I used for testing along with all the sections I commented out.
NewIP.txt
NewIP.txt
ASKER
it does the 'Response.Write("final date2: " & finaldate2 & " this is new IP: "&NewIP) '
and I was getting tat as well.. but it doesn't do 'SQLstr = "SELECT * FROM Contestvotes where dateadded = #" & finaldate & "# and LoginIP = '" & NewIP & "'" '
nothing happens I get the response write at the top but the compare selection in the do while and the response at the bottom do nothing as if the 'do while' isn't finding anything.
and I was getting tat as well.. but it doesn't do 'SQLstr = "SELECT * FROM Contestvotes where dateadded = #" & finaldate & "# and LoginIP = '" & NewIP & "'" '
nothing happens I get the response write at the top but the compare selection in the do while and the response at the bottom do nothing as if the 'do while' isn't finding anything.
Don't know what to tell you. It's works exactly as described here. I would have to add entries for it to find anything for today. 'today' is the date it is comparing it to. Your code won't find anything else as it is written.
ASKER
date records I have been using:
Table: Contestvotes
dateadded selection loginIP
5/8/2015 2 64.180.179.174
5/10/2015 1 64.114.228.241
5/10/2015 2 64.114.229.185
structure:
dateadded Date/Time
selection Text(50)
loginIP Text(15)
It in theory it should only find the second record ... the ip listed is my IP so I should get the 'sorry you can't vote again until tomorrow'
All I want is to prevent someone from adding a second vote until the next day. If there is a better way to do this, I am all ears. To me, my code seemed to be simple logical way to achieve this .. but apparently not
: (
Table: Contestvotes
dateadded selection loginIP
5/8/2015 2 64.180.179.174
5/10/2015 1 64.114.228.241
5/10/2015 2 64.114.229.185
structure:
dateadded Date/Time
selection Text(50)
loginIP Text(15)
It in theory it should only find the second record ... the ip listed is my IP so I should get the 'sorry you can't vote again until tomorrow'
All I want is to prevent someone from adding a second vote until the next day. If there is a better way to do this, I am all ears. To me, my code seemed to be simple logical way to achieve this .. but apparently not
: (
It's a weird one. Apparently ASP VBscript is still aware of the 'date' format when you do the comparison. When I used 'Cstr' to convert it, then it works. Updated code attached.
NewIP.txt
NewIP.txt
ASKER
we are half waythere. the 'sorry' displays but when I changed the last day I voted to 5/8/2015 I should get the contest message but is goes to the 'sorry' message.
I tried changing the sql to
SQLstr = "SELECT * FROM Contestvotes where dateadded < #" & finaldate & "# and LoginIP = '" & NewIP & "'"
And all I got was a blank page ...
I tried changing the sql to
SQLstr = "SELECT * FROM Contestvotes where dateadded < #" & finaldate & "# and LoginIP = '" & NewIP & "'"
And all I got was a blank page ...
That version with '<' is doing a string comparison, not really a date comparison.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think you did it !!! I will try this in the morning ... my brain is FULL
ASKER
But it looks like it worked !! I truly can't thank you enough!! Happy Happy
ASKER
Like I said ... Happy Happy !!!
A further addition because you want the most recent entry first...
SQLstr = "SELECT * FROM Contestvotes where LoginIP = '" & NewIP & "' ORDER BY dateadded DESC""
You're welcome, glad to help.
Open in new window