Re: CGI.pm and form creation

2005-01-17 Thread Tor Hildrum
On Mon, 17 Jan 2005 14:41:40 +0100, Mauro [EMAIL PROTECTED] wrote:
 I'm trying to create a little form usign CGI.pm but I get this error from 
 apache:
  malformed header from script. Bad header=form method=post action=/c: 
 /usr/lib/cgi-bin/make_graph_CPU_form.pl.cgi
 
 this is my perl code:
 
 #!/usr/bin/perl
 use CGI qw/:standard/;
 
 sub print_form {
 print start_form,
 Metriche:,
  checkbox(-name='usr',-checked=1),
  checkbox(-name='sys',-checked=0),
  checkbox(-name='wio',-checked=0),
  checkbox(-name='idle',-checked=0),
  reset(-name='Reset'),
  submit(-name='Go!'),
  end_form;
 };
 
 print header,
 start_html('RRDTool CPU Usage Monitor'),
 h1('RRDTool CPU Usage Monitor'),
 print_form(),
 Nothing to it!\n,
 end_html;

Replace the above with:

## start headers
print header, start_html(foo), h1(bar);

print_form();

## end html
print end_html;

The problem is that print_form() is evaluated to early in the code or
something :)
 
Tor

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: CGI.pm and form creation

2005-01-17 Thread Moon, John
I'm trying to create a little form usign CGI.pm but I get this error from
apache:
 malformed header from script. Bad header=form method=post action=/c:
/usr/lib/cgi-bin/make_graph_CPU_form.pl.cgi

this is my perl code:

#!/usr/bin/perl
use CGI qw/:standard/;

sub print_form {
print start_form,
Metriche:,
 checkbox(-name='usr',-checked=1),
 checkbox(-name='sys',-checked=0),
 checkbox(-name='wio',-checked=0),
 checkbox(-name='idle',-checked=0),
 reset(-name='Reset'),
 submit(-name='Go!'),
 end_form;
};

print header,
start_html('RRDTool CPU Usage Monitor'),
h1('RRDTool CPU Usage Monitor'),
print_form(),
Nothing to it!\n,
end_html;

I don't understand why apache tells:action=/c:
/usr/lib/cgi-bin/make_graph_CPU_form.pl.cgi when the form prints out form
method=post action=/./make_graph_CPU_form.pl.cgi
enctype=application/x-www-form-urlencoded
Could you help me?

Please replace :
snip 
sub print_form {
print start_form,
/snip

with 

snip

sub print_form {
return start_form,
/snip

...

You can also always see what you are generating by running the cgi script
from the commamd prompt... 

DEV,SUN2./foo.cgi
(offline mode: enter name=value pairs on standard input)
{reply ctrl+d}
Content-Type: text/html

!DOCTYPE HTML PUBLIC -//IETF//DTD HTML//EN
HTMLHEADTITLERRDTool CPU Usage Monitor/TITLE
/HEADBODYH1RRDTool CPU Usage Monitor/H1FORM METHOD=POST
ENCTYPE=application/x-www-form-urlencoded
Metriche:INPUT TYPE=checkbox NAME=usr VALUE=on CHECKEDusr
INPUT TYPE=checkbox NAME=sys VALUE=onsys
INPUT TYPE=checkbox NAME=wio VALUE=onwio
INPUT TYPE=checkbox NAME=idle VALUE=onidle
INPUT TYPE=reset VALUE=ResetINPUT TYPE=submit NAME=Go!
VALUE=Go!INPUT TYPE=hidden NAME=.cgifields VALUE=usrINPUT
TYPE=hidden NAME=.cgifields VALUE=idleINPUT TYPE=hidden
NAME=.cgifields VALUE=wioINPUT TYPE=hidden NAME=.cgifields
VALUE=sys/FORMNothing to it!
/BODY/HTMLDEV,SUN2



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response