Does anyone had experience with this problem before? Trying to call this script from HTML page, but everytime It gave me a blank page. I'm using PHP Version 4.2.2. Thanks
The reason is because of the localhost part of the URL.
Localhost always points to 127.168.0.1 - which is the computer you're currently using. So, if anyone tries to click on that link, it will look for a webserver on their own computer!
Now, if this page was written just for you...with a list of links that [only you can access], then you've just gone about it the wrong way. Using http:// means that you need a web server to return the page. What you'd want then is file://c:/bookB/redirect_form.html.
Thanks for your respond, some how I'm still getting the same problem. When I run this page below from my local server, it does not load my do_redirect.php . All I tried to do is redirect some the URL to a new location. By the way, I already turn on the register_globals in the php.ini config file. Anyone has other suggestion, thanks
You are right folk, I have written the php script to check out the IP address. It turns out to 127.0.0.1, also my computer runs on P2P network through a router. This IP address is the loop back IP address, so I believe this is the reason that the server does not load my do_redirect.php file. I have tried to run this file by itself, it loaded back to my redirect_form.html file, and no error message display. I also tried to to take out the exit; line, it's still run into the same problem. Any folks has other ideas, please share your, thank a lot.
Just a stab in the dark, but try renaming $location to something else, like $location1, it might be a reserved word for a function or something, if that doesn't do anything, try this
I have tried that script, it gave me HTTP 404 error (file cannot be found)
orangehairedboy,
All my php script is running on my own computer (my own web server). I have no ideas why It keep giving the same problem on my Windows 2000. I have similar web server runs on Windows XP without any problems, all php scripts run very good.
*By the way, I have no problem running this script from my webserver. It works fine.
<?php
//if its MSIE then
//go to Spoono.com
if ($name = strstr ($HTTP_USER_AGENT, "MSIE")) {
Header ("Location: http://www.spoono.com/");
}
//else go to to yahoo.com
else {
Header ("Location: http://www.yahoo.com/");
}
?>
I noticed that you had <?php on the script that worked and <? on the script that didn't...you never know...I also changed $location to $_GET{location}...make sure you submit the form with the GET method.
Also, I'm wondering if the script is working fine, but the file it used to point to (the http://localhost/bookB... address) was the problem...
The script you have above works fine. I tried to substitute the header with one of my URL, which is http://localhost/bookB/redirect_form.html"); It starts giving me problem. I reviewed the error log page of the Apache server, it shows the following
[Mon Mar 03 01:09:18 2003] [error] [client 127.0.0.1] Premature end of script headers: c:/php/php.exe
I can open that redirect_form.HTML in the browser without any problem. It just can not load the do_redirect.php script.
Okay, here is what I found out. I took the redirect_form.hmtl and do_redirect.php script put them in the Web Server on my Windows XP computer. The code worked very well, without any problem. So I believe I must have done something wrong some where during the process of installing of PHP or Apache. That's why it keeps give problem. I guess that I have to reinstall these software again.
Lastly, I'd like to say thanks for all your helps. I'm really appreciate them. Thanks