Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

CGI::FormBuilder malformed header

by hesco (Deacon)
on Feb 18, 2010 at 23:12 UTC ( #824050=perlquestion: print w/replies, xml ) Need Help??
hesco has asked for the wisdom of the Perl Monks concerning the following question:

I'm using CGI::FormBuilder, my constructor includes header => 1, templates => '/path/to/template.html', and I'm getting this error:

malformed header from script. Bad header=<?xml version="1.0" encoding= +": volunteer.cgi
Doesn't this mean it is not getting the Content-Type? Shouldn't header being set to 1 generate such an animal? When I add a print $q->header(); to the mix, it resolves the issue. But I would have thought that setting header => 1, in the constructor would do the trick.

-- Hugh

if( $lal && $lol ) { $life++; }
if( $insurance->rationing() ) { $people->die(); }

Replies are listed 'Best First'.
Re: CGI::FormBuilder malformed header
by Khen1950fx (Canon) on Feb 19, 2010 at 07:16 UTC
    I borrowed an example from the formbuilder website. They used header => 1 towards the end of the script. It works for me:
    #!/usr/bin/perl use strict; use warnings; use CGI::FormBuilder; my @fields = qw(name email password confirm_password zipcode); my $form = CGI::FormBuilder->new( method => 'post', fields => \@fields, validate => { email => 'EMAIL', phone => 'PHONE', }, required => 'ALL', ); if ( $form->submitted ) { my $fname = $form->field('first_name'); $fname = $form->field('last_name'); print $form->confirm( header => 1 ); } else { print $form->render( header => 1 ); }
Re: CGI::FormBuilder malformed header
by Anonymous Monk on Feb 18, 2010 at 23:37 UTC
    That is not code proof

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://824050]
Approved by ww
Front-paged by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2018-11-15 09:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (182 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!