Re: mising html code with (outside) quickform code - howwhere to use ob_start() ?

From: Date: Fri, 01 Apr 2005 20:01:10 +0000
Subject: Re: mising html code with (outside) quickform code - howwhere to use ob_start() ?
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18481@lists.php.net to get a copy of this message
On Apr 1, 2005 11:51 AM, l Burnerheimerton <lburnerheimerton@yahoo.com> wrote: > I need to use quickform inside a dreamweaver template. > I know I could use a templating system but time > permits not this time. > > Quickform processes the form but when it tries to go > to another page using > > header("Location: file.php") > > I get the error indicating "header info has already > been sent". This isn't QuickForm's fault. You're outputting somewhere above that code. See my FAQ: http://opensource.21st.de/tiki-index.php?page=PHPFAQs#id482883 > > Basically, I have the code below. If ob_start() would > work to avoid the error above (and I think it will), > please let me know where to use it. If you put ob_start() at the very top of your code (before anything else is done) then the loaction header should still work. Alternatively you can check to see if a header has been sent and use JS / meta refresh techniques instead. Here's a function I've been using: function redirect($url) { //MSIE on the mac does not do Location headers correctly if ((!stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE') || !stristr($_SERVER['HTTP_USER_AGENT'], 'Mac')) && !headers_sent()) { header('Location: '.$url); } echo '<script language="JavaScript1.1"> <!-- location.replace("'.$url.'"); //--> </script> <noscript> <meta http-equiv="Refresh" content="0; URL='.$url.'"/> </noscript> This page has moved to a <a href="'.$url.'">new location</a>. '; } > > Thanks! > > require_once('HTML/QuickForm.php'); > $form = new HTML_QuickForm('form1'); > ....//build form > if ($form->validate()) { > $form->process('process_data', false); > header("Location: anotherfile.php"); > exit; > } > > function process_data ($valuesDate) { > ....//process form data > } > > <html> > <head> > .... > -- Justin Patrin

« previous php.pear.general (#18481) next »