arahant Posted January 28, 2010 Share Posted January 28, 2010 Hi, I use the following code to redirect to task_list.php after a successful login $host = $_SERVER['HTTP_HOST']; $uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\'); $extra = 'task_list.php'; header("Location: http://$host$uri/$extra"); //header("location: task_list.php"); exit; This code was working fine till now until suddenly the header("Location: http://$host$uri/$extra") doesnt seem to work at all. If i remove the exit then the rest of the page is displayed. Has anyone experienced this before? I checked to see if there was some PHP version upgrade going on but that doesnt seem to be the case. I'm pretty much stumped. Any help is appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/190078-php-redirect-just-stopped-working/ Share on other sites More sharing options...
Yucky Posted January 28, 2010 Share Posted January 28, 2010 Couldn't be your browser by any chance could it? Your code works just fine here on 5.2.9. Quote Link to comment https://forums.phpfreaks.com/topic/190078-php-redirect-just-stopped-working/#findComment-1002876 Share on other sites More sharing options...
arahant Posted January 28, 2010 Author Share Posted January 28, 2010 I have actually tried it on different browsers with or without recent history deleted. Also the code works on my local machine (v 5.2.6). It worked on the server as well (v 4.3.9) but has suddenly stopped working Quote Link to comment https://forums.phpfreaks.com/topic/190078-php-redirect-just-stopped-working/#findComment-1002879 Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2010 Share Posted January 28, 2010 For debugging purposes, add the following two lines of code immediately after your first opening <?php tag - ini_set("display_errors", "1"); error_reporting(E_ALL); Quote Link to comment https://forums.phpfreaks.com/topic/190078-php-redirect-just-stopped-working/#findComment-1002880 Share on other sites More sharing options...
arahant Posted January 28, 2010 Author Share Posted January 28, 2010 Thanks! It gave me a warning that header was already modified and output started in an included file called backend_api.php. Although backend_api.php consisted purely php code, there was a newline char at the end which caused the problem. Strangely though I dont remember modifying this file! Quote Link to comment https://forums.phpfreaks.com/topic/190078-php-redirect-just-stopped-working/#findComment-1002885 Share on other sites More sharing options...
PFMaBiSmAd Posted January 28, 2010 Share Posted January 28, 2010 It is likely that the extra character was always in the file but that output_buffering was turned on in the master php.ini, thereby hiding the problem. The output_buffering setting likely got turned off by your web host. Quote Link to comment https://forums.phpfreaks.com/topic/190078-php-redirect-just-stopped-working/#findComment-1002888 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.