PDA

View Full Version : cgi wants to download not execute


jsarrel
03-14-2006, 01:27 AM
Here are two simple scripts I'm trying to run:

-------------------------------------------------
junk1.cgi:

#!/usr/bin/perl -wT

use strict;
use CGI;

my $cgi = new CGI;
print $cgi->header("text/plain");

print <<EOT;
<html>
<body>
<form method="GET" action="junk2.cgi">
<input name="text" type="text">
<input type="submit" value="Submit">
</form>
</body>
</html>
EOT

--------------------------------------------------
junk2.cgi:

#!/usr/bin/perl -wT

use strict;
use CGI;

my $cgi = new CGI;
print $cgi->header("text/plain");

print "These are the paramters I received:\n\n";

my ($name,$value);

foreach $name($cgi->param){
print "$name:\n";
foreach $value( $cgi->param($name)){
print " $value\n";
}
}
----------------------------------------------
Basically the first script is just a textbox and a submit button.
The second script displays the parameters from the referring page.
If I set the method to GET on the first script it runs correctly. If I set the method to POST I get a prompt to save/open instead of running.
I do not want to use GET, the pages I will be doing will have 20-30 fields in them.
I'm not sure where to start, permissions are set, .cgi is setup as a valid perl extension. This is on a reseller account so I don't have that much access to system files. Any ideas?
Thanks!

Jason

FishMonger
03-14-2006, 02:09 AM
print $cgi->header("text/plain");

should be

print $cgi->header("text/html");

or just leave it out of the call.

print $cgi->header;

jsarrel
03-14-2006, 02:12 AM
Doh! Yep, that was it. This is the first time I've used the CGI module to any extent. I figured it was a minor error somewhere. Thanks a lot!

Jason