alishan Posted December 7, 2006 Share Posted December 7, 2006 Hi Members!I want to redirect user to another page after sign in or other activity, but when I use header, an error comes that header is already defined,.Regards, Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/ Share on other sites More sharing options...
Vikas Jayna Posted December 7, 2006 Share Posted December 7, 2006 This happens because headers need to be sent before any other output in the script. Even a whitespace character sent to the browser before call to header() function will give error. Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/#findComment-136835 Share on other sites More sharing options...
Hamlets666 Posted December 7, 2006 Share Posted December 7, 2006 You can not use header location if you print something before/after sending header. Use html redirect! Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/#findComment-136838 Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 Did you see the big [url=http://www.phpfreaks.com/forums/index.php/topic,37442.0.html]sticky[/url] at the top of the baord? Read it. Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/#findComment-136839 Share on other sites More sharing options...
alishan Posted December 7, 2006 Author Share Posted December 7, 2006 what is html redirect and how can I use it ?[quote author=Hamlets666 link=topic=117719.msg480451#msg480451 date=1165497886]You can not use header location if you print something before/after sending header. Use html redirect![/quote] Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/#findComment-136846 Share on other sites More sharing options...
Hamlets666 Posted December 7, 2006 Share Posted December 7, 2006 [code]<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.phpfreaks.com/index.php">[/code]Put it between between the <HEAD> and </HEAD>. Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/#findComment-136849 Share on other sites More sharing options...
alishan Posted December 7, 2006 Author Share Posted December 7, 2006 I need to redirect user after creating session or after saving data into the database.It does not work in phpafter session. Is there any other way, please ?[quote author=Hamlets666 link=topic=117719.msg480462#msg480462 date=1165498284][code]<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.phpfreaks.com/index.php">[/code]Put it between between the <HEAD> and </HEAD>.[/quote] Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/#findComment-136860 Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 Read the link I posted!!! Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/#findComment-136861 Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 Sorry, I actually just read that link and while it states the cause, it offers no solution.The simplest solution is to use output buffering. This ensures that the headers are all sent together.[code]<?php ob_start(); // your code ob_end_flush();?>[/code] Link to comment https://forums.phpfreaks.com/topic/29803-problem-in-redirection-using-header/#findComment-136863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.