Dynadot โ€” .com Transfer

How to display appropriate content by checking the ip address?

NamecheapNamecheap
Watch

bbalegere

Established Member
Impact
18
I want display a particular content in my site to visitors whose ip addresses begin with 61.*.*.*
Can anyone give me code to do this?
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
Unstoppable Domains โ€” AI StorefrontUnstoppable Domains โ€” AI Storefront
PHP:
$ip=explode(".", $_SERVER['REMOTE_ADDR']);
if ($ip[0] = '61') {
//Content Displayed to those users here
}


Bear
 
0
•••
Bear is on the money. That will do the trick. They are a few additions that could be added for other ip addresses if you have multiple.
 
0
•••
Thanks a lot Bear.
Here is another question.
Now i want to display a particular content to only a particular geographic area.
How do I find to which geographic a particular ip address belongs and display content only to those ip addresses?
 
0
•••
http://www.ip2location.com is what I use althought they are now charging for their product but it works great. Basically you will need a database that has the IP ranges in it and they will probably need converted to hex and then you can run a query on the database to come up with your country code. I think I still have the older version they were giving out for free of IP2LOCATION shoot me a PM if you are interested.
 
0
•••
Appraise.net
Spaceship
Domain Recover
CatchDoms
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back