doby_p Posted March 3, 2011 Share Posted March 3, 2011 Hi, Im new to all this coding stuff but get by ok with help from the wealth of info on the internet however in this instance i cant solve a PHP redirect issue im having. Ive got a very simple php script to redirect to a secure paypal item link using the header function. header("Location:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XYX96W3MSFQZ6"); The problem is when the script is called upon in IE it loops endlessly however works perfectly in Chrome, Firefox, Opera and the Andriod stock browser. I originally tried the redirect directly within the meta tag although this failed on all browsers so now i have the meta tag point to this PHP file. (The meta tag is in a script that submits form data and displays a temporary 'redirecting...' page. Has anyone expirenced this problem before or know of ways to fix it for IE? Could it be an issue with security in IE because the paypal link is secure? Any help would be greatly appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/229502-php-headerlocation-looping-only-in-ie/ Share on other sites More sharing options...
Muddy_Funster Posted March 3, 2011 Share Posted March 3, 2011 what do you meen it "loops endlesly"? is this code on the target page as well? Quote Link to comment https://forums.phpfreaks.com/topic/229502-php-headerlocation-looping-only-in-ie/#findComment-1182470 Share on other sites More sharing options...
doby_p Posted March 3, 2011 Author Share Posted March 3, 2011 After clicking to submit the form data it displays the 'redirecting' page for 2 seconds, emails me the form data and the meta tab calls on a php script to redirect to the paypal link however in IE it just loops the 'redirecting' page and never resolves to paypal. Im not sure what you mean by having the code on the target page, see the process below. Form submit script <?php /* subject and email variables */ $emailSubject = 'LightFold Order'; $webMaster = '[email protected]'; /* gathering data variables */ $nameField = $_POST['name']; $surnameField = $_POST['surname']; $emailField = $_POST['email']; $phoneField = $_POST['phone']; $address1Field = $_POST['address1']; $address2Field = $_POST['address2']; $cityField = $_POST['city']; $countyField = $_POST['county']; $postcodeField = $_POST['postcode']; $countryField = $_POST['country']; $body = <<<EOD <br><hr><br> Name: $nameField <br> Surname: $surnameField <br> Email: $emailField <br> Phone: $phoneField <br> Address1: $address1Field <br> Address2: $address2Field <br> City: $cityField <br> County: $countyField <br> Postcode: $postcodeField <br> Country: $countryField <br> EOD; $headers = "From: $email\r\n"; $headers = "Content-type: text/html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); /* results renderd as HTML */ $theResults = <<<EOD <html> <head> <title>Redirecting To Paypal</title> <meta http-equiv="refresh" content="2;paypalredirect.php"> <style type="text/css"> <!-- body { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 20px; font-style: normal; line-height: normal; font-weight: normal; text-decoration: none; padding-top: 200px; margin-left: 120px; width: 520px; background-image: url(bg.gif); background-repeat: repeat; text-align: center; } --> </style> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head> <div align="center" id="message"> <p><img src="redirectingtopaypal.png" width="240" height="22"></p> <p><img src="spinner.gif" width="32" height="32"></p> </div> </div> </body> </html> EOD; echo "$theResults"; ?> Paypal Redirect Script <?php header("Location:https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=XYX96W3MSFQZ6"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/229502-php-headerlocation-looping-only-in-ie/#findComment-1182507 Share on other sites More sharing options...
Muddy_Funster Posted March 3, 2011 Share Posted March 3, 2011 that shouldn't work at all regardless of what browser you use :- you can't execute a header(location:) after returning data to the browser. Now you've got me confused . And please use the forum code or php tags when posting code. Quote Link to comment https://forums.phpfreaks.com/topic/229502-php-headerlocation-looping-only-in-ie/#findComment-1182524 Share on other sites More sharing options...
n3r0x Posted March 3, 2011 Share Posted March 3, 2011 personally i never use header("Location:$url"); I Use header('refresh:'.$timeoutperiod.';url='.$url); that way i can set a timeout before the redirect should occur. (never had a problem in IE ever) Quote Link to comment https://forums.phpfreaks.com/topic/229502-php-headerlocation-looping-only-in-ie/#findComment-1182532 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.