DarkReaper Posted June 13, 2006 Share Posted June 13, 2006 Okay so i have a header of the page which displays some information about the user. Unfortunatelly this header is updated on every click. And the problem is that when i click on the main page for something lets say change my name. On the next page load it will remain the same because the header is displayed before the main body (where the changes take place). So after i reload the page one more time, then i have the updated info. Any ideas how to avoid this? My first guess was to cache all of the header in a session ... but that failed to workout. Basically i want to process the request first then to display the whole page in 1 piece. Help?! :) Quote Link to comment https://forums.phpfreaks.com/topic/11884-php-header-and-body-changes/ Share on other sites More sharing options...
trq Posted June 13, 2006 Share Posted June 13, 2006 How exactly are you including this [i]header[/i]? Is it a frame or something? Use the include() function which makes the page into 1 before sending it to the client. Quote Link to comment https://forums.phpfreaks.com/topic/11884-php-header-and-body-changes/#findComment-45088 Share on other sites More sharing options...
joquius Posted June 13, 2006 Share Posted June 13, 2006 just load your code before the html header. Quote Link to comment https://forums.phpfreaks.com/topic/11884-php-header-and-body-changes/#findComment-45092 Share on other sites More sharing options...
DarkReaper Posted June 13, 2006 Author Share Posted June 13, 2006 @thorpe: yes i use include.@joquius: the html and the code are so implemented in one another that i cant distictly classify them :( ... any other ideas? Quote Link to comment https://forums.phpfreaks.com/topic/11884-php-header-and-body-changes/#findComment-45178 Share on other sites More sharing options...
joquius Posted June 13, 2006 Share Posted June 13, 2006 oh got you. just add header ("location: ".$PHP_SELF); //or something similiarafter each change which requires a refresh. (add it before your html). Wouldn't trust $php_self though, you're better off specifying the page.if you have already output html, just use?><script type="text/javascript">location = '<?=$PHP_SELF?>';</script><? Quote Link to comment https://forums.phpfreaks.com/topic/11884-php-header-and-body-changes/#findComment-45199 Share on other sites More sharing options...
DarkReaper Posted June 13, 2006 Author Share Posted June 13, 2006 Hm i still think you dont understand me so i will provide maybe a better example:$_SESSION['username'] by default in our example has a value of "test";header.php-------------echo $_SESSION['username'];-------------main.php-------------$_SESSION['username'] = 'as;lkd';-------------So when i load the page at first i will see the 'test' and after i hit refresh i will see 'as;lkd'I want to display the new property without refreshing twice. Which will happen if i used the following construction:$_SESSION['username'] by default in our example has a value of "test";main.php-------------$_SESSION['username'] = 'as;lkd';-------------footer.php-------------echo $_SESSION['username'];-------------As output i will get 'as;lkd', and not 'test' as in the first example. I hope you understand me now. Quote Link to comment https://forums.phpfreaks.com/topic/11884-php-header-and-body-changes/#findComment-45228 Share on other sites More sharing options...
joquius Posted June 13, 2006 Share Posted June 13, 2006 well it's impossible to get a value which is set later, you would have to export the var to javascript via var = <?=$phpvar?> and then write that var to the header in a javascript once all the php has loaded (obviously).Unless you can set the username attribute before any html is sent Quote Link to comment https://forums.phpfreaks.com/topic/11884-php-header-and-body-changes/#findComment-45266 Share on other sites More sharing options...
DarkReaper Posted June 14, 2006 Author Share Posted June 14, 2006 thanks the javascript trick is working :) ... its a little bit annoying .. but hey its my fault :)thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/11884-php-header-and-body-changes/#findComment-45399 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.