Hello, This is a reply to an e-mail that you wrote on Sun, 10 Aug 2003 at 00:24, lines prefixed by '>' were originally written by you. > This may be a stupid question, but I'm trying to set up a system where > I can > take a poll from visitors to my website and then set a cookie so that > they > can't vote more than once (until they clear their cookies at least). > Problem is, I don't want to put it at the top of my page, because what > somebody opens up a poll but decides not to vote, then later changes > his > mind. The cookie will prevent him from voting. I want the cookie to > be set > right after the user clicks the vote button, but every time I do that, > I get > an error about headers already being sent. Is there any way around > this?
You cannot send any headers after you have sent output as this is how HTTP works, a set of headers are sent, double newline, then all the content. You can't go back in time and add more headers. There are two ways round your problem... 1. Set your cookie right at the top of the script, so as your first line have something like: if(isset($_POST['vote'])){ setcookie(....); } 2. Use output buffering, this will make PHP buffer all of your content and not send it till you tell it to (or until it reaches the end of the file). Read more at: http://uk.php.net/ref.outcontrol All the best, David. -- phpmachine :: The quick and easy to use service providing you with professionally developed PHP scripts :: http://www.phpmachine.com/ Free PHP error handling script: www.phpmachine.com/error-handler/ Professional Web Development by David Nicholson http://www.djnicholson.com/ QuizSender.com - How well do your friends actually know you? http://www.quizsender.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php