Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Can I compare IP addresses with the DB?


jswan

Recommended Posts

Hi folks:

 

I'm really scratching my head here. I think my php skills may be insufficient to figure this out. I am using the Pollbooth contribution to find out how customers find the site. I want the pollbooth box to display for a new customer, but not for someone who already has voted.

 

I know Pollbooth has a function that determines if a user has an IP address that matches the ones in the DB, but I can't figure out how to make it work from my index page (if the IP doesn't match the ones in the DB, display Pollbooth box, else display the rest of the page).

 

So, every time someone votes in Pollbooth, the IP address is stored in a table called phesis_poll_check. I need to know how to get the array of stored addresses and how to compare the curent user's address

 getenv("REMOTE_ADDR")

with the array so that I can set up my if statement.

 

Can someone show me an example of the code that compares on value with an array of values?

 

Thanks in advance,

 

Jason

Link to comment
Share on other sites

I lost the rest of my post... :o

 

You could do something like this:

 

$sql = mysql_db_query('select ips from iptable where ip=getenv['remote_addr']);

if (mysql_num_rows($sql) > 0)

do not display survey

else

display survey

 

of course you would have to correct the syntax but generally it should work for what you are looking for.

Link to comment
Share on other sites

  • 3 weeks later...

Thanks for responding to this question. Pollboth does have an option that checks the user IP. But then it still displays the poll results. I wanted to set it up so that the box doesn't display at all if the poll has been taken. I ended up using a variety of the solution that vasttech suggested. I selected the IP from the table that matches the users IP. Then, if there is no match, I displayed the box.

 

Thanks again,

 

Jason

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...