Prince99 has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monks,
I am writing a perl script using CGI.pm to allow add/edit/delete of positions available. Things seemed to be going well and I thought I was starting to understand this module a little. I was soon disappointed to learn that my understanding was less than stellar. I generate a html page with the following sub procedure:

sub PrintForm { &Open_File; &Read_File; &Close_File; print header( -type => 'text/html' ), start_html( -title => 'PMI Human Resources', -background=>'/yellow_stucco.gif'), start_form(-method => 'post', -action => 'editpositions.pl'), scrolling_list(-name=>'list_name', -values => \@JobTitle, -size => 1), br, br, submit(-name => 'Add', -value => 'Add Position'), br,br; if (@JobTitle) { print submit(-name => 'Edit', -value => 'Edit Position'), br,br, submit(-name => 'Delete', -value => 'Delete Position'), br,br, end_form; } print start_form(-method => 'post', -action => '../EditDeptInfo.p +l.bak'), hidden('Manager', 'Manager'), submit(-name => 'Cancel', -value => 'Cancel'), end_form, end_html;


The following section of code should take care of a user pressing the submit button named Add.

print header(-type => 'text/html\n\n'), start_html(-title => 'PMI Human Resources', -background=>'/yellow_stucco.gif'), start_form(-method => 'post', -action => 'editpositions.pl' ), "What is the Job Title?", textfield('JobTitle', '', 30, 80), br, br, "What is the Date Listed?", textfield( 'DateListed', '', 30, 80), br, br, "What is the Job Description?", textarea('Description', '', 10, 80), br, br, submit(-name => 'AddFile', -value=> 'AddFile'), end_form, start_form( -method => 'post', -action => 'editpositions.pl'), p, hidden('Manager', 'Manager'), submit(-name => 'submit', -value=> 'Cancel'), end_form, end_html; }

Now I am using -w and Use strict; in my code and have declared the proper scoped variables to make this work. The problem is that when a user hits the Add submit button, they get a file download popup window. It shouldn't. I may be missing something that is causing it, but my eyes are bleeding from staring at this code. Any help/insight would, as always, be appreciated.

Prince99

Too Much is never enough...

Replies are listed 'Best First'.
Re: cgi improper file upload???
by petdance (Parson) on Jun 07, 2001 at 00:32 UTC
    You don't want those \n\n in the string you pass to header. For that matter, you can leave that -type parm out entirely, since CGI.pm assumes it's text/html.

    Not sure if that's causing a problem, but having too many \n's can't be a good thing in your header.

    xoxo,
    Andy

    %_=split/;/,".;;n;u;e;ot;t;her;c; ".   #   Andy Lester
    'Perl ;@; a;a;j;m;er;y;t;p;n;d;s;o;'.  #   http://petdance.com
    "hack";print map delete$_{$_},split//,q<   andy@petdance.com   >
    
      That seemed to do the trick. I guess I got caught up in the type param. Thanks much for your help.

      Prince99

      Too Much is never enough...