Jump to content


Photo

header("Location: http://domain.com"); not working.


  • Please log in to reply
6 replies to this topic

#1 blazing_bruce

blazing_bruce
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationIndia

Posted 19 March 2006 - 07:55 PM

hello,
i am using a script named work.php for two purpose .
1. displaying banner image
2. checking remote address and putting clicks and hits informations in tables
2.1 after making these data base operations, redirecting browser to the $rediurl by using header();

$rediurl = // my url
header("Location:$rediurl");

i spliting my script by two separate if conditions.
1st condition for displaying image by
echo("<center><a href=\"$hrf\"><img src=\"$banurl\"> <br> </a></center>");

in second condition i am checking ip and date values, after that trying to redirect.
by:
mysql_close($connection);
echo("until db Close "); // this is for debugging process
header("Location: $rediurl");
i can get dbclose acknowledgement too. the header line didn't executed.
Pleaese help me.

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 19 March 2006 - 07:57 PM

The manual very clearly states:

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
Remember that header() must be called before any actual output is sent, either by normal HTML tags, blank lines in a file, or from PHP.
[/quote]

[a href=\"http://www.php.net/header\" target=\"_blank\"]http://www.php.net/header[/a]

#3 blazing_bruce

blazing_bruce
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationIndia

Posted 19 March 2006 - 08:04 PM

then how can i redirect to $rediurl? i want to redirect by based on some conditons.

Please help me.

Thank you,
Karthi keyan.

#4 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 19 March 2006 - 08:10 PM

[!--quoteo(post=356470:date=Mar 19 2006, 03:04 PM:name=blazing_bruce)--][div class=\'quotetop\']QUOTE(blazing_bruce @ Mar 19 2006, 03:04 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
then how can i redirect to $rediurl? i want to redirect by based on some conditons.

Please help me.

Thank you,
Karthi keyan.
[/quote]

Add ob_start(); to the very beginning of your script (First line of it) and then add ob_end_flush(); to the very end of your script (last line) and the header redirects will work just fine :)

#5 blazing_bruce

blazing_bruce
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationIndia

Posted 19 March 2006 - 08:19 PM

Great Prismatic,
Thanks :)

Really it is redirecting me. but one problem. i am using that redirecting line inside <iframe> tag so redirect url's content is showing inside of that iframe. if you are not clear with me then have a look at [a href=\"http://karthi.livesoft.info\" target=\"_blank\"]http://karthi.livesoft.info[/a] i want to load redirection page fully in browser atleast open in new window.

Please help me,

Thank you,
Karthi keyan.

#6 blazing_bruce

blazing_bruce
  • Members
  • PipPip
  • Member
  • 28 posts
  • LocationIndia

Posted 19 March 2006 - 09:01 PM

Hello,
i fixed this problem now. by embedding simple java script lines. like
?>
<script language="javascript" type="text/javascript">
<!--
Newsite= window.open("<?php echo("$rediurl"); ?>","newsite");
// -->
</script>
<?

Thank you friends and PHP Freaks.

Thank you,
Karthi keyan.

#7 Prismatic

Prismatic
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego

Posted 19 March 2006 - 09:57 PM

[!--quoteo(post=356499:date=Mar 19 2006, 04:01 PM:name=blazing_bruce)--][div class=\'quotetop\']QUOTE(blazing_bruce @ Mar 19 2006, 04:01 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Hello,
i fixed this problem now. by embedding simple java script lines. like
?>
<script language="javascript" type="text/javascript">
<!--
Newsite= window.open("<?php echo("$rediurl"); ?>","newsite");
// -->
</script>
<?

Thank you friends and PHP Freaks.

Thank you,
Karthi keyan.
[/quote]


window.location would probably suit you better :)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users