From: "Andrea Bakker" on
I've googled this topic quite a bit and I don't think I understand the way quickform works. The following code gives the headers already sent error. My login_test_form is just a simple quickform with 2 username & Password. Does the $loginform->validate() send header info ? If so how can I ever redirect without getting the "headers already sent" error ?

<?php
$pagename = 'login';
include('config.php');
include(DIR_APPLICATION . '/lib/user.lib.php');
include(DIR_APPLICATION . '/lib/advert.lib.php');
include(DIR_APPLICATION . '/lib/defaultformrenderer.lib.php');
include('functions.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">
<?php include('inc/header.php');
include('inc/topmenu.php');
include('inc/logmenu.php');

?>
<div id="wrapper" class="clearfix">
<div id="maincontentuser">
<?php
$renderer = new DefaultFormRenderer($loginform);
include('inc/head.php');
$renderer->display();
?>
</div>

</div> <!-- end wrapper div -->
<?php include('inc/footer.php'); ?>
</div> <!-- end maincontainer div -->
</body>
</html>
From: Mark Steudel on
Show us your code in login_form_test.php and probably default renderer.

Can you comment all there lib/*php files and see if the problem goes away?

Make sure you don't have any extra spaces at the top of your pages.

Something like this works just fine:

$form = new HTML_QuickForm( 'newForm' );

$form->addElement( 'text', 'varname', 'Lable:' );

if( $form->validate() ) {
header( "location: someotherfile.php");
exit;
}
else {
$form->display();
}

On Fri, Mar 12, 2010 at 12:56 AM, Andrea Bakker <abakker(a)telkomsa.net> wrote:
> I've googled this topic quite a bit and I don't think I understand the way quickform works.  The following code gives the headers already sent error.  My login_test_form is just a simple quickform with 2 username & Password.   Does the $loginform->validate()   send header info ?   If so how can I ever redirect without getting the "headers already sent" error ?
>
> <?php
> $pagename = 'login';
> include('config.php');
> include(DIR_APPLICATION . '/lib/user.lib.php');
> include(DIR_APPLICATION . '/lib/advert.lib.php');
> include(DIR_APPLICATION . '/lib/defaultformrenderer.lib.php');
> include('functions.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">
>        <?php include('inc/header.php');
>           include('inc/topmenu.php');
>              include('inc/logmenu.php');
>
>        ?>
>        <div id="wrapper" class="clearfix">
>         <div id="maincontentuser">
>                <?php
>              $renderer = new DefaultFormRenderer($loginform);
>        include('inc/head.php');
>        $renderer->display();
>        ?>
>    </div>
>
>  </div> <!-- end wrapper div -->
>  <?php include('inc/footer.php'); ?>
> </div> <!-- end maincontainer div -->
> </body>
> </html>
>



--

-----------------------------------------
Mark Steudel
P: 206.375.7244
msteudel(a)gmail.com

.. : Work : .
http://www.mindfulinteractive.com

.. : Play : .
http://www.steudel.org/blog