Checking IP then redirecting
Moderator: General Moderators
Checking IP then redirecting
how would i go about checkin a users ip address that is visiting my site... then by usng that ip address i would redirect them to another page
i know the ip address i want to redirect
i heard one simple php page would do this
i know the ip address i want to redirect
i heard one simple php page would do this
Code: Select all
<?php
$visitors_ip = $_SERVER['remote_addr'];
echo "Your ip is: $visitors_ip";
?>Code: Select all
<?php
$ip = 127.0.0.1;
if($REMOTE_ADDR == $ip) {
//DIRECT TO PAGE WHATEVER
} else {
//whatever u want to do if the IP is not the same
}
?>- redhair
- Forum Contributor
- Posts: 300
- Joined: Fri May 30, 2003 4:36 pm
- Location: 53.23N-6.57E
- Contact:
Code: Select all
<?php
$ip_visit = getenv("REMOTE_ADDR");
$ip_array[] = "127.0.0.1"; //popcup
$ip_array[] = "216.239.59.104"; //your friend
foreach ($ip_array as $ip_match)
{
if (preg_match("/$ip_visit/","$ip_match"))
{
header ("location:http://www.php.net");
}
}
?><html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#FFFF99" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php
$ip_visit = getenv("REMOTE_ADDR");
$ip_array[] = "62.252.128.12 "; //popcup
foreach ($ip_array as $ip_match)
{
if (preg_match("/$ip_visit/","$ip_match"))
{
header ("location:http://www.php.net");
}
}
?>
<table width="75" height="78" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body bgcolor="#FFFF99" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<?php
$ip_visit = getenv("REMOTE_ADDR");
$ip_array[] = "62.252.128.12 "; //popcup
foreach ($ip_array as $ip_match)
{
if (preg_match("/$ip_visit/","$ip_match"))
{
header ("location:http://www.php.net");
}
}
?>
<table width="75" height="78" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
</tr>
</table>
</body>
</html>
The following is a part of some code that i wrote.
Make use of it 
Code: Select all
<?php
}
else if($ID == 13)
echo "<script>location.replace("/forum/index.php")</script>";
else if($ID == 43){
echo "<script>location.replace("/sponsor/")</script>";
}
else {
echo "<a href=indexm.php class=forumlink>Beklenmeyen komut seçimi!!!</a>";
}
?>