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, Quote Link to comment 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. Quote Link to comment 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! Quote Link to comment 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. Quote Link to comment 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] Quote Link to comment 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>. Quote Link to comment 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] Quote Link to comment Share on other sites More sharing options...
trq Posted December 7, 2006 Share Posted December 7, 2006 Read the link I posted!!! Quote Link to comment 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] Quote Link to comment 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.