I need a hand...
<clap><clap>
I need to write a link into a page depending on the IP address of the visitor
i.e. if the visito comes from 192.40.40.* the link is this, else the link is this1
sounds simple but couldnt find the PHP function let alone how to accomplish the host mask.
ip address if statement
Moderator: General Moderators
Code: Select all
$m = '192.40.40.';
if (strncmp($m, $_SERVER['REMOTE_ADDR'], strlen($m)) == 0)
{
}
else
{
}almost
Alrighty, so the deal is "if your on my local network go here, else go here... here is what i have.. thnak you
The problem is that it is always returning the ELSE... any clue?
Code: Select all
<?
$m = "192.111.0.;
if (strncmp($m, $_SERVERї'REMOTE_ADDR'], strlen($m)) == 0)
{
print('192.111.0.50');
}
else
{
print('12.211.111.211:1601');
}
?>The problem is that it is always returning the ELSE... any clue?
work quite right for memy webserver is reachable via 192.168.0.1 or world interface
Code: Select all
<?php
$m = '192.168.0.';
echo $_SERVER['REMOTE_ADDR'], '<br />';
echo $m, '<br />';
if (strncmp($m, $_SERVER['REMOTE_ADDR'], strlen($m)) == 0)
{
print('local network');
}
else
{
print('world');
}
?>
done.