Page 1 of 2
why header("location") doesn't work?
Posted: Wed Feb 08, 2006 3:27 am
by mesutsahin
We have an e-commercial web site and we should redirect our customers to a result page according to the response of the bank.
Although there is no error message, header("location:xxxx.php"); doesn't work in any browser.
Also this code works for other banks perfect without any error.
But for one bank it doesn't work without any error.
Some php.ini configuration:
display_errors:on
output_buffering:on
Code: Select all
if($approved==true){
header("location:".HTTPS_SERVER."/successful.php");
exit();
}
else{
header("location:".HTTPS_SERVER."/fail.php");
exit();
}
after sending form with that bank, this code is just doing exit() by skipping header("locaiton") row.
Thank you for your help.
Posted: Wed Feb 08, 2006 3:40 am
by feyd
Is HTTPS_SERVER a defined constant? Is it correct?
Posted: Wed Feb 08, 2006 3:40 am
by Benjamin
I am guessing here...
1. Perhaps that server doesn't support redirects.
2. Perhaps one of the files was saved in a format (eg dos) or uploaded in binary which is causing it to output data so it can't send the redirect because the header was already sent.
3. Perhaps one of the files were corrupted when uploaded.
4. Perhaps the one particular web site is using a different url scheme. (eg
http://domainname.com instead of
http://www.domainname.com)
Posted: Wed Feb 08, 2006 3:53 am
by quocbao
and perhap your browser disable redirect
Try other browser
Posted: Wed Feb 08, 2006 4:09 am
by khaki_monster
HI!
i once had problems regarding with Header() function, but tanx for this forum i was able to solved it.
here's the origenal('Links') question that i throw before:
viewtopic.php?t=43784
and this was the given example that solved my problem.
viewtopic.php?t=1157
feyd actually give me this link

thanx man!
hope this may help a bit...
cheerz!
header location doesn't work
Posted: Wed Feb 08, 2006 5:19 am
by mesutsahin
1. Perhaps that server doesn't support redirects.
2. Perhaps one of the files was saved in a format (eg dos) or uploaded in binary which is causing it to output data so it can't send the redirect because the header was already sent.
3. Perhaps one of the files were corrupted when uploaded.
4. Perhaps the one particular web site is using a different url scheme.
1.server supports redirects. Because it works for other banks.
2.All files have php extension
3.no, they are not corrupted. We have checked them.
4. url scheme
http://www.zzzzzzzzzzzzzzz.com
If the headers are already sent, php would show an error. In my ini configuration display error = on
It doesn't show any error.
Posted: Wed Feb 08, 2006 5:39 am
by quocbao
as i said : try other browser
I met this problem once when i used FireFox and when i tested it with IE it worked fine
be careful , because you can also disable location header in IE so be sure to enable it

maybe
Tools -> Internet Options -> Advanced -> Enable page transition
Posted: Wed Feb 08, 2006 5:45 am
by mesutsahin
I am trying with all browsers including(IE,Netscape,Firefox,Opera).
It works on the server side. I don't think it's about the browser.
It makes no sense that I have made the settings in my browser.
How can I tell all the customers to change the browser settings.
Posted: Wed Feb 08, 2006 6:23 am
by quocbao
It makes no sense that I have made the settings in my browser.
How can I tell all the customers to change the browser settings.
Opps , as a web developer , browser is important . Maybe your website work 100% on IE but when using FF or other browsers they may work only 80-90% ( design interface , javascript , css , etc ... )
If you don't want to change your browser setting , then you can use this
Code: Select all
<?
function redirect($url)
{
header('location: ' . $url);
?>
<meta http-equiv="Refresh" content="0; url=<?=$url?>" />
<script language=javascript>window.location = "<?=$url?>"</script>
<?
exit;
}
?>
Posted: Wed Feb 08, 2006 6:34 am
by phpScott
try
Code: Select all
//given
define ("HTTPS_SERVER", "https://www.somesite.com");
if($approved==true){
$location = "location:".HTTPS_SERVER."/successful.php";
header("{$location}");
exit();
}
else{
$location = "location:".HTTPS_SERVER."/fail.php";
header("{$location}");
exit();
}
as I remeber something weird happening when I tried doing something similar and the header go grumpy at me for not having things quoted right, so I did the above and it worked.
EDIT>> changed the tags before I got in trouble
it didn't work.
Posted: Wed Feb 08, 2006 8:01 am
by mesutsahin
it didn't work.
Posted: Wed Feb 08, 2006 9:59 am
by mesutsahin
Any of the ideas posted above has not solved my problem.
There is some exceptional situation here that I couldn't understand. There is no error message.
PHP is skipping header("locaciton:") line. It executes the line below (exit()). It exits and shows a white page.
Posted: Wed Feb 08, 2006 10:03 am
by feyd
Are you absolutely sure there's no errors? Have you checked the server logs?
I've run into a few situations where a header() call was genuinely being skipped. Adding a call to flush() or other things that force the headers to be output helped, that I remember.
Posted: Wed Feb 08, 2006 10:59 am
by Maugrim_The_Reaper
Wondering. Is it required to insert a space between the header name and value?
Location:
http://example.com
vs
Location:
http://example.com
Just seems to be the one thing sticking out here that I've never done. No clue myself, and can't test it for now.
Posted: Wed Feb 08, 2006 11:32 am
by Christopher
I am also wondering based on that "HTTPS_SERVER" ($_SERVER['SERVER_NAME'] ?) whether it is: