envexlabs Posted October 5, 2007 Share Posted October 5, 2007 Hey, I know how to redirect using header(), but i have a quick question. I know that you have to send the redirect before all the header information, but if i have a form being processed halfway down the page via, $_SESSION[php_self], how do i go about redirecting after the form has been processed? Thanks, envex Quote Link to comment https://forums.phpfreaks.com/topic/71978-redirect-confusion/ Share on other sites More sharing options...
logicopinion Posted October 5, 2007 Share Posted October 5, 2007 <? $username = $_post['username']; $password = $_post['password']; if (isset($username) && isset($password)) { mysql_query(update db set password = '$password', username = '$username' where id = userid); } header ("location:http://www.site.sufix/folder"); ?> This is the way to redirect such a script Quote Link to comment https://forums.phpfreaks.com/topic/71978-redirect-confusion/#findComment-362562 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 ummm, yes. I'm not sure what the problem is? can you restate? you can use session variables before a header(); Quote Link to comment https://forums.phpfreaks.com/topic/71978-redirect-confusion/#findComment-362566 Share on other sites More sharing options...
envexlabs Posted October 5, 2007 Author Share Posted October 5, 2007 Hey, I know how to redirect, but the form is being processed half way down the page, after all the header has been rendered. Quote Link to comment https://forums.phpfreaks.com/topic/71978-redirect-confusion/#findComment-362567 Share on other sites More sharing options...
BlueSkyIS Posted October 5, 2007 Share Posted October 5, 2007 if that's the problem, move processing to the top before output. if there is a chance that you might need header(), you HAVE to do it before ANY information goes to the browser. that is the only way, there is no (decent) option. Quote Link to comment https://forums.phpfreaks.com/topic/71978-redirect-confusion/#findComment-362570 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.