Jump to content

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


blazing_bruce

Recommended Posts

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.
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

[!--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) [snapback]356470[/snapback][/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 :)
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

[!--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) [snapback]356499[/snapback][/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 :)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.