Results 1 to 12 of 12
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Using IP Address as Query Filter (2002)

    Hi,

    I'm building a website that has a form that saves data to a database. The purpose of the form is for the user to select photo's that they will want copies of. Whan the form is saved to the database, the IP address is saved as well. This will be the unique identifier for the user's selections. I plan to have a form that will be based on a query and will show the choices the user made. I need to be able to filter the query based on the IP address. My problem is I don't want to have the user have to enter their own IP (as most won't know it) and I want the page, as it opens, to query the database. Is this even possible and if so, how would I determine the IP to use in the query?

    Thanks,
    Leesha

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Using IP Address as Query Filter (2002)

    I don't do web development, so I cannot answer your question, but are you sure that the IP address is a good identifier? Although most people nowadays have (A)DSL or cable where the IP address remains the same for an extended period of time, there are still many people on dial-up where the IP address is assigned dynamically by the ISP. And people might browse from different PCs. You could ask people to register a username, or use their e-mail address.

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using IP Address as Query Filter (2002)

    Hi Hans,

    As always you've given me food for thought. The reason I picked the IP address is that it seemed to be the only common thread between the pages when they are saved to the database. I'd do have a page for them to enter user name, email etc. and that page also has the IP address. This is sooooooooooooooo different than programming in Access but I'm too stubborn to let it beat me! And I thought Access was hard to "get". This is like pulling teeth since I keep "seeing" how I'd do it in Access and it just doesn't work that way in Frontpage.

    Leesha

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Using IP Address as Query Filter (2002)

    The ASP Request object should contain the IP address. Check out http://www.w3schools.com/asp/coll_servervariables.asp Example 2.

  5. #5
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using IP Address as Query Filter (2002)

    Sorry for the delay in replying, but you really shouldn't use the IP address to identify something with a web user.

    Instead, create a user id and set it as a cookie. Have each page check to see if a session object 'exists'. If it does, that object is the user's 'id'. If not, check for a cookie (you can set and read web users local cookies for your sight) value.

    Now, this is a stripped down version of actually having user accounts, where a user has a username and password. (using the cookies will work, but if someone wipes out their cookies, they'd get a 'new' account the next time.

  6. #6
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using IP Address as Query Filter (2002)

    Hi Drew,

    It must be fate, i've just been starting back at this yet again. And to think I thought Access was hard to tackle. I can "see" what I want to do but creating it..................OMG. OK so at the risk of sounding like a total newbie at this (I've really tackled a lot in the past months) how do I set a user id as a cookie?

    Thanks,
    Leesha

  7. #7
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using IP Address as Query Filter (2002)

    google for request.cookie and response.cookie. The first 'reads' cookies from the web user, the other writes.

    I started with Access 97, taught myself how to write VBA code, and about 2 years later decided to give asp a whack...haven't turned back since. I love web interfaces, they have some distinct advantages over anything else (with only a few drawbacks).

    If you have the MSDN installed, take a look at the ASP Built in Objects reference card. Pretty handy.

  8. #8
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using IP Address as Query Filter (2002)

    I just bought an ASP book and hope to start digging in to it. Jerry gave me a link to a site he likes as well with tutorials etc. Keep you fingers crossed!!

    Thanks,
    Leesha

  9. #9
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using IP Address as Query Filter (2002)

    Cool, well if you have any specific questions, give me a holler.

    Have you ever made an asp page?

  10. #10
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using IP Address as Query Filter (2002)

    Hi Drew!

    I'm taking you up on your offer for a hand with asp. I've been working at this for days and more hours than I can count. I've have a registration page that submits information to an access database. The asp code has been generated by FP. I have set the database fields to not allow duplicates in the email field. This is working fine in that when the user submits their information, if the email address is already there, the row is not duplicated. My problem is that the confirmation page automatically populates making it look like the data was entered (when it was in fact blocked as it should be) and there is no error stating that the database wouldn't accept the new record. I tired doctoring up the code generated by FP to look to see if the email address is already present and if it is to give an error but it didn't work. Would you look at my code and see what I'm missing. I'm surrounded by .asp books but obviously am missing something. The code I added is in bold, red, itallics. The rest of the code is the code generated by FP.

    Thanks!
    Leesha
    Attached Files Attached Files

  11. #11
    4 Star Lounger
    Join Date
    Aug 2002
    Location
    Dallas, Texas, USA
    Posts
    594
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Using IP Address as Query Filter (2002)

    Ok, I'm a little busy at the moment, trying to get a project for work done, so I don't have the time to modify the code for you. But here's what you should do. Where it is opening the recordset, change that line to open a SQL statement that queries for that email address...then check for EOF/BOF. (Stay away from filters in a recordset....). If there is a record, close the recordset, and create the HTML you want to display, otherwise, close the recordset, reopen it (like the original line) add the record and display whatever you want for that.

    To display different data to the user, use conditional formatting:

    <%If x=something then%>
    This text is displayed to the user if x=something, it's HTML, so
    would display to the end user as a line break
    <%else%>
    This is displayed if x doesn't equal something
    <%end if%>

    Within conditional formatting, you can 'place' variables into the html with <%=something%> like this:

    Hello <%=rs.fields("UserName").value%>

    hope this helps.

  12. #12
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Using IP Address as Query Filter (2002)

    Thanks, I'll give it another shot.

    Leesha

Posting Permissions

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