jose07 Posted January 22, 2011 Share Posted January 22, 2011 Hey guys, I have a problem, i'm using ob_start to send multiples headers and it works but the problem is that my metada is not being sent, when i remove the ob_start it gets sent. Is there a way i can allow more info to be sent with ob_start? or should i use other methods to redirect to pages? i dont want to use javascript or meta http because they are not very reliable is there any other way? Thanks for help. Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/ Share on other sites More sharing options...
trq Posted January 22, 2011 Share Posted January 22, 2011 header works fine for redirecting. Why you want to send data to a client only to redirect them is beyond me, it makes no sense at all to do so. Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163488 Share on other sites More sharing options...
jose07 Posted January 22, 2011 Author Share Posted January 22, 2011 i have a page that allows users to see the contents of it only if they are logged in, so it checks for that and re-directs them accordingly (two header locations, welcome page or sign in page) if i don't use ob_start i get error 'headers already sent' because i believe it starts from other scripts(i have one for a header where all metadata is stored/retrieved from db). When i used ob_start i don' t get the errors and the re-direction works fine, however, my metadata is not sent google doesn't find my tags and is this extra info thats not being sent. I've tried to add ob_end_flash but it doesn't seem to help. Hope that makes sense Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163498 Share on other sites More sharing options...
trq Posted January 22, 2011 Share Posted January 22, 2011 You need to also display your meta only if the user is logged in. Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163499 Share on other sites More sharing options...
jose07 Posted January 22, 2011 Author Share Posted January 22, 2011 yes at the moment it only displays if the user's logged in, but i'd like it displayed regardless. Is there a way to do that with ob_? Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163514 Share on other sites More sharing options...
trq Posted January 22, 2011 Share Posted January 22, 2011 yes at the moment it only displays if the user's logged in, but i'd like it displayed regardless. Is there a way to do that with ob_? If all you are going to do is redirect there is no point is there. Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163535 Share on other sites More sharing options...
jose07 Posted January 22, 2011 Author Share Posted January 22, 2011 what you mean theres no point? I want google to be able to find my site, if i post link of one of the contents(restricted or not) it should be able to find the metada, tags related to it. Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163544 Share on other sites More sharing options...
trq Posted January 22, 2011 Share Posted January 22, 2011 People (or Google) are not logged in the will be redirected and never see the meta tags anyway. The short answer is that you cannot output anything and then redirect, it also makes NO SENSE at all to try. Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163547 Share on other sites More sharing options...
jose07 Posted January 22, 2011 Author Share Posted January 22, 2011 hmmn i don't know if you understand what i'm writing? I'm not redirecting people to a different site, only to log in page if they're not logged in. Example: If i look for 'php forums' on google 'phpfreaks' will come up because the metadata and tags 'php,forum' are associated with phpfreaks but it doesn't mean i can post without registering and because i haven't registered doesn't mean google won't find you when i do a search? and when i get to phpfreaks i'm redirected to a log in or subscribe page. Now the content that users can see(on my site) once logged in have tags associated with them that google should index but its not doing at the moment because it can't find it. ob_ is stopping that info flow Does it make sense now? Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163564 Share on other sites More sharing options...
trq Posted January 22, 2011 Share Posted January 22, 2011 It makes perfect sense. Always did. The difference is we do not redirect users to a login page if they are not logged in and are trying to access our index. This is what you seem to be doing. Google cannot index pages it can't access, eg, it cannot index our admin pages because it can't login. If you want your pages to be open to Google they need to be open to the public. Now, 1 more time. You cannot send data to the browser and then send headers. Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163568 Share on other sites More sharing options...
jose07 Posted January 22, 2011 Author Share Posted January 22, 2011 Ok, users can easily access my index and my index is also easily found on google. i have articles in different categories, some articles are free to see and others the user has to log in to see. I understand your point but note that If i use javascript to redirect the user my metadata works, even if the user has javascript disabled they won't see the article and will still have to log in. I guess this works because i'm not sending headers? I didn't want to use javascript but i guess if using headers will stop the metadata then i'll use java for now until i figure a work around headers or php is improved. What do you think, suggest? Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163585 Share on other sites More sharing options...
trq Posted January 22, 2011 Share Posted January 22, 2011 It doesn't sound like your code is well organized to me. WE would need to see your code to be able to help but basically, (and Ive said this before) it makes no sense to output data if your going to redirect anyway. Quote Link to comment https://forums.phpfreaks.com/topic/225292-php-header/#findComment-1163760 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.