Jump to content

Recommended Posts

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. 

Link to comment
https://forums.phpfreaks.com/topic/190078-php-redirect-just-stopped-working/
Share on other sites

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!

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.

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.