Jump to content

Archived

This topic is now archived and is closed to further replies.

TecBrat

I did read the pinned note about headers, but...

Recommended Posts

I am incoporating an existing script into my site. The problem I am having is that their script is sending headers. (My novice skills barely understand what that means.) What I've done is where I usually include my own content, I have an if (!foo='' || !bar=''){ their_code(); } where foo and bar as well as others like them are the variables I found that it uses.
Their script had a selection to disable a header warning. I selected that. Then I get to another part of the application that includes an email form. I submit the form, and the email is sent. (I received it) but the page gives a header already sent error.
I can supress the error by putting @ in front of the function they use to call their whole program, But any code I put after the dying function is not executed. I tried using or die() and it did not work either. I tried putting ob_flush(); right before their function, but I still got the error. (I had never heard of ob_flush before I read that pinned note.)
Any ideas?
The only thing I need to do after it dies is give the user a message and send them back to the home page.

Share this post


Link to post
Share on other sites
what about adding a if statement.

//a varable holds data if it's there send them somewere.
if($whatever="what_ever") {

header("location: whatever.com");

}

Share this post


Link to post
Share on other sites
just put the following code at the very top i promise it make the headers work anywhere
[code]
<?php
ob_start();
?>
[/code]

Share this post


Link to post
Share on other sites
i realize i suggested using output buffering (very unclearly) in my pinned topic, but that DOES NOT FIX THE HABIT THAT FORMS THESE ERRORS.

billybob, please stop recommending this as a solution to everyone's header issues.

tecbrat:  i'd like to start by saying thank you for reading the pinned topic, however unhelpful it is (i posted it a LONG time ago).  as ken said, we'd need to see your code to get an idea of how to fix the issue in this instance..

Share this post


Link to post
Share on other sites
billybob:  this forum is NOT about "have them stoped whinning," it's about solving problems, and hopefully in such a way that the problem is avoided in the future.  i've edited my pinned topic to be clearer and more descriptive.  read it again and maybe you won't have to use ob_start() in the future yourself.

redarrow:  i'm not sure he's in a spot to know where to put that if(), and whether it would work.  we need to see more code to know what he's dealing with.

Share this post


Link to post
Share on other sites
WOW! That was a lot of replies in a hurry.
This worked. I found a solution that did not send another header.
Most of my problems stem from using other people's code, and not knowing what they were doing.
[code]
?>
<meta http-equiv="refresh" content="0; url=<?echo($url);?>">
<?
//header('Location: ' . $url);
[/code]

Share this post


Link to post
Share on other sites
um i use cookies for login and thats how to set them up how do u make the user stay loged in

Share this post


Link to post
Share on other sites
[quote author=BillyBoB link=topic=100621.msg397383#msg397383 date=1152924622]
just put the following code at the very top i promise it make the headers work anywhere
[code]
<?php
ob_start();
?>
[/code]
[/quote] Lol, it makes me laugh that you always suggest output buffering and everyone says not to use it. XD

Share this post


Link to post
Share on other sites
billybob, what are you talking about?

Share this post


Link to post
Share on other sites
im saying how do u make the user login

so that u dont have to use the dredful ob_start();

Share this post


Link to post
Share on other sites
read my pinned topic, it has been changed to be clearer.  if you still have troubles understanding, post a new topic.

Share this post


Link to post
Share on other sites
[quote author=BillyBoB link=topic=100621.msg397498#msg397498 date=1152934020]
im saying how do u make the user login

so that u dont have to use the dredful ob_start();
[/quote]
Just put session_start(); at the top of the page. Ditch the cookies, and use sessions. They're more secure anyways.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.