Page 2 of 2
Posted: Fri Feb 20, 2004 7:22 pm
by redhair
popcop wrote:aaargggghhhh..... i cant get this to work
Are you running php at all?
Try this code, and tell me if it works:
Code: Select all
<?php
$ip = getenv("REMOTE_ADDR");
echo $ip;
?>
Do you see your ip when you run this?
Posted: Fri Feb 20, 2004 7:22 pm
by dethron
Just write the following to a blank page, then save it.
And request this file server via browser.
Code: Select all
<script>location.replace('http://www.borsacini.com')</script>
Does it work?
If not, we should search other things to find the problem; because there is nothing wrong with this code-line.
(!!dont forget browser compatibility, i didnt checkhed which of those supports location.replace)
By the way, what is your browser?
Posted: Fri Feb 20, 2004 7:27 pm
by dethron
By the way compatibility for window.location.replace is
IE 4.0+, NS 4.0+, Mac/Win
Posted: Fri Feb 20, 2004 7:29 pm
by redhair
Why not use header
Code: Select all
<?php
header ("location:http://www.php.net");
?>
Works with all browsers.
Posted: Fri Feb 20, 2004 7:31 pm
by dethron
Yes redhair, it is possible too.
Actually, considering bc(browser compatibility), your suggestion is better.
Posted: Fri Feb 20, 2004 7:41 pm
by redhair
considering cs(common sence) I would just use
this. Posted earlier in this topic.
But popcop says 'it doesnt ~seem~ to be working',....
Posted: Fri Feb 20, 2004 7:45 pm
by popcop
xcxc
Posted: Fri Feb 20, 2004 7:45 pm
by dethron
Since location.replace is works for me until now, I haven't complain about it

)
But now, I found a better substitude for location.replace considering both cs and bc
Thnx.
Posted: Fri Feb 20, 2004 7:54 pm
by dethron
Since it works for simple code. It must also work for the complex code except the complex code has another problem.
Add a line that echos the $REMOTE_ADDR
What is the remote address? Are you sure it is 62.252.128.12
Posted: Fri Feb 20, 2004 7:56 pm
by popcop
yeah i was testin it on myself to see if would work but it never
Posted: Fri Feb 20, 2004 8:00 pm
by dethron
Code: Select all
<?php
echo "<html><head><title>Untitled Document</title></head> ";
echo "<body>";
$ip = "62.252.128.12";
if($REMOTE_ADDR == $ip) {
echo "red queen";
}
echo "</body></html> ";
?>
Try this code, did you see the red queen?
Posted: Fri Feb 20, 2004 8:01 pm
by d3ad1ysp0rk
are you sure that's your ip?
go here to find your IP:
http://www.optikhosting.com/~des404/ip.php
Posted: Fri Feb 20, 2004 8:02 pm
by d3ad1ysp0rk
dethron, your code will only work if register globals is on..
Posted: Fri Feb 20, 2004 8:04 pm
by dethron
Then add a line to my code
Code: Select all
<?php
//I am assuming the register global is on
?>
Thnx for correction.
Posted: Fri Feb 20, 2004 9:47 pm
by evilMind
The reason why it's not working is because you have sent the headers already (when you opened output to the client)
Try this. Move ALL of the php code before ANY HTML output. In fact, make sure that there is no output sent to the client before you try to use the header function (*note* blank lines at the end of a file can cause headers to be sent).
eg:
Code: Select all
<html>
<head><title>Foo</title></head>
<body>
<?php
if ($_SERVERї'REMOTE_ADDR'] == '127.0.0.1') {
header('Location: http://www.foo.com/');
exit(0);
}
?>
<!-- This will NOT work -->
</body>
</html>
but....
Code: Select all
<?php
if ($_SERVERї'REMOTE_ADDR'] == '127.0.0.1') {
header('Location: http://www.foo.com/');
exit(0);
}
?>
<html>
<head><title>Foo</title></head>
<body>
Hi :)
<!-- This WILL work -->
</body>
</html>