/    Sign up×
Community /Pin to ProfileBookmark

Detect IP Address Then Display Image/Button, Otherwise Do Nothing?

Here is how I have my button setup on my website, very clean, with a simple rollover. Here is my question, can php load an image based on someone’s ip address? What I mean by that, our website, is going public, some page are pulling data from our database, agency listing, faq and so forth. I want our ip range 192.0.0.0 to 192.0.0.255 to be decteded, if so then load image below. If not, then do nothing. Can anyone help me write this script if its possible, I need this like asap. I will continue to search all over the internet in the meanwhile. Thanks.

[code=php]
<tr>
<td width=”188″ height=”20″>
<a href=”link.php” onmouseover=”sub_navigation_image1.src=’img1_rollover.jpg’;” onmouseout=”sub_navigation_image1.src=’img1_rollover.jpg’;”>
<img name=”sub_navigation_image1″ src=”img1_ready.jpg” border=0 width=”188″ height=”20″ alt=”Button1″ onMouseOver=”(window.status=’Button’); return true” onMouseOut=”(window.status=”); return true”></a></td>
</tr>
[/code]

to post a comment
PHP

11 Comments(s)

Copy linkTweet thisAlerts:
@ConorMay 13.2004 — just do like

[code=php]
if($_SERVER['REMOTE_ADDR']=="ip here")
{
//do code
}
else{
//do nothing
}
[/code]


to do more then one ip just do an or statement

[code=php]
if($_SERVER['REMOTE_ADDR']=="ip here" || $_SERVER['REMOTE['ADDR']=="other ip")
{
//do code
}
else{
//do nothing
}
[/code]
Copy linkTweet thisAlerts:
@d_brandusaauthorMay 13.2004 — How can you do a wildcard detect ip? Lets just say detect, if ip starts with 192.*.*.* and anything after the 192. is fine then load image. How do I do that? Or to the second code you did, how do you tell it "between" the first and the second ip is fine! It dectects the servers ip not the user!?
Copy linkTweet thisAlerts:
@ConorMay 13.2004 — try this
[code=php]
$ip=$_SERVER['REMOTE_ADDR'];
if(eregi("192(.*)", $ip))
{
//perorm code
}
else {
//do nothing
}
[/code]
Copy linkTweet thisAlerts:
@d_brandusaauthorMay 13.2004 — I did this as a test, but my ip address starts with 69 and it said hello!

[code=php]
<?php

$ip=$_SERVER['REMOTE_ADDR'];
if(eregi("192(.*)", $ip))
{
echo "Hello";
}
else {
echo "Nope";
}

?>
[/code]
Copy linkTweet thisAlerts:
@ConorMay 13.2004 — it displayed nope for me when i did 192 but when i change it to 24 it says hello so it works for me.
Copy linkTweet thisAlerts:
@d_brandusaauthorMay 13.2004 — Is there something that is configured wrong with our server perhaps?
Copy linkTweet thisAlerts:
@ConorMay 13.2004 — it says nope for me
Copy linkTweet thisAlerts:
@d_brandusaauthorMay 13.2004 — Thanks...i'm such a dumbass, I forgot I use ravlinsoft to connect securely to work and it must replicate my computers ip address to make it seem like i'm there! Thanks so much RefreshF5, your awesome!
Copy linkTweet thisAlerts:
@ConorMay 13.2004 — no problem ?
Copy linkTweet thisAlerts:
@d_brandusaauthorMay 13.2004 — What would the code be if i want it to be any ip address with .domain.com after it.

So virtually any ip address our domain gives to our users but it must follow .domainname.com? Our domain. Is that possible?
Copy linkTweet thisAlerts:
@ConorMay 13.2004 — could you clarify I dont really understand what you mean
×

Success!

Help @d_brandusa spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...