rduval
asked on
PHP Redirect to completely different site
I'm taking info from a form posting, generating an email then I want to redirect to a completely different site (paypal actually to process the payment).
That site will kick back to me when I'm done but how do I get to the other site?
I've tried using:
Header("Location: https://www.paypal.com/xclick/business=paypal%40nl4x4%2eca&undefined_quantity=1&item_name=Northern%20Lights%204x4%20Trailriders%20Assoc%20Membership&amount=25%2e00&no_shipping=1&return=http%3a%2f%2fwww%2enl4x4%2eca%2fsignup%2fcomplete%2ephp¤cy_code=CAD");
but I get:
Warning: Cannot modify header information - headers already sent by (output started at C:\vhome\nl4x4\signup\send mail_gopay pal.php:9) in C:\vhome\nl4x4\signup\send mail_gopay pal.php on line 26
Any ideas kids?
That site will kick back to me when I'm done but how do I get to the other site?
I've tried using:
Header("Location: https://www.paypal.com/xclick/business=paypal%40nl4x4%2eca&undefined_quantity=1&item_name=Northern%20Lights%204x4%20Trailriders%20Assoc%20Membership&amount=25%2e00&no_shipping=1&return=http%3a%2f%2fwww%2enl4x4%2eca%2fsignup%2fcomplete%2ephp¤cy_code=CAD");
but I get:
Warning: Cannot modify header information - headers already sent by (output started at C:\vhome\nl4x4\signup\send
Any ideas kids?
ASKER
I need something I can do at the end, after all the other scripting is done.
If I call the header first won't it re-direct me before anything else is done?
If I call the header first won't it re-direct me before anything else is done?
> If I call the header first won't it re-direct me before anything else is done?
It depends on the condition.
<?php
if(something IS true) {
header("Location: http://www.domain.com");
exit();
}
else {
echo "something is false, you can echo the display here";
}
?>
If still unclear, please show some code.
It depends on the condition.
<?php
if(something IS true) {
header("Location: http://www.domain.com");
exit();
}
else {
echo "something is false, you can echo the display here";
}
?>
If still unclear, please show some code.
Try the following meta tag(quick and dirty method)
It can redirect your page even after you output anything. Although it's not recommended.
<?php
// target of the redirect
$url = "https://www.paypal.com/";
// 0 second delay
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='. $url.'">';
?>
The meta goes in the head of the HTML, or anywhere else.
This method does not require javascript and is supported by most browsers and is rarely, if ever, filtered out.
It can redirect your page even after you output anything. Although it's not recommended.
<?php
// target of the redirect
$url = "https://www.paypal.com/";
// 0 second delay
$delay = "0";
echo '<meta http-equiv="refresh" content="'.$delay.';url='.
?>
The meta goes in the head of the HTML, or anywhere else.
This method does not require javascript and is supported by most browsers and is rarely, if ever, filtered out.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Just add ob_start(); as first line in your php script!
I was having the same problem and got it fixed with this!
I was having the same problem and got it fixed with this!
Only if you add ob_end_flush() at the end as well.
There should not be even a single white space before the php starting tag.
I mean :
<?php // correct.
<?php // wrong, notice the white space before the <?php tag.
Possible solutions are :
1) Move the echo statements (if any) in your code after all the header functions. ( OR )
2) Assign the echo statements in a variable and call it after the header function.
3) Set output buffering ( http://www.php.net/ob_start )