headers already sent on login with quickform

From: Date: Mon, 15 Mar 2010 10:38:12 +0000
Subject: headers already sent on login with quickform
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30408@lists.php.net to get a copy of this message
I've googled this topic quite a bit and I don't think I understand the way quickform works. I have reduced my code to the minimum and am still getting headers already sent . My login_test_form is just a simple quickform with a username & Password. I've taken out all rules. Does the $loginform->validate() send header info ? If so how can I ever redirect without getting the "headers already sent" error ? Below is the main code. logtest.php $pagename = 'login'; include('config.php'); include(DIR_APPLICATION . '/lib/login_form_test.php'); if(isset($_POST['Login'])) {if ($loginform->validate()) { // Form is validated, then processes the data $url = HTTP_SERVER . "listing.php"; header("Location: $url"); exit; } } ?> <body> <div id="maincontainer"> <div id="wrapper" class="clearfix"> <div id="maincontentuser"> <?php include('inc/head.php'); $loginform->display(); ?> </div> </div> <!-- end wrapper div --> </div> <!-- end maincontainer div --> </body> </html> login_form_test.php <?php require_once 'HTML/QuickForm.php'; PEAR::setErrorHandling(PEAR_ERROR_DIE); $loginform = new HTML_QuickForm('loginForm'); $loginform->addElement('header', null, 'Enter Your Details Below'); $loginform->addElement('text', 'username', 'User Name:', array('size' => 30, 'maxlength' => 30, 'class'=>"label")); $loginform->addElement('password', 'password', 'Password :', array('size' => 32, 'maxlength' => 30)); $loginform->addElement('submit', 'Login', 'Login'); $loginform->addElement('link','fp_link','', 'forgotpassword.php', 'Forgot Password', '_target="blank"'); $loginform->applyFilter('username', 'trim'); $loginform->addRule('username', 'Please enter your User Name', 'required'); $loginform->addRule('password', 'Please enter your Password', 'required'); ?> inc/head.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>JBay Kids site</title> <meta name="description" content="For all your kids entertainment and activities in the Jeffreys Bay area." /> <meta name="keywords" content="" /> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="css/jbaykids.css" /> <!--[if IE]> <link rel="stylesheet" type="text/css" href="css/ie.css" /> <![endif]--> <script language="JavaScript" type="text/JavaScript"> <!-- function MM_jumpMenu(targ,selObj,restore){ //v3.0 eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'"); if (restore) selObj.selectedIndex=0; } function MM_openBrWindow(theURL,winName,features) { //v2.0 window.open(theURL,winName,features); } //--> </script> </head>

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