click submit ->starts downloading perl file......dont want it to happen 
Author Message
 click submit ->starts downloading perl file......dont want it to happen
i got a simple form which looks like this:

<form name="feedback" action="cgi-bin/feedback.pl" method="post">

  <input type="text" name="name" value="">

  <select name="age" size="1">
  <option selected>Choose Age...</option>
  <option value="under16">Under 16</option>
  <option value="17-20">17 - 20</option>
  <option value="21-30">21 - 30</option>
  <option value="31-40">31 - 40</option>
  <option value="over41">Over 41</option>
  </select>

  <textarea name="comment" rows="3" cols="25"></textarea>
  <input type="submit" name="submit" value="Send Feedback!">
  <input type="reset" name="clear" value="Clear Feedback!">

</form>

The perl script is as follows (its a tutorial book, which im using and
should work with any form):

#!/C:/perl/bin/perl.exe

my(%form);

getFormData(/%form);

# data procesing statements

sub getFormData {
        my($hashRef) = shift;
        my($buffer) = "";

        if ($ENV{'REQUEST_METHOD'} eq 'GET') {
                $buffer = $ENV{'QUERY_STRING'};
        }
        else {
                read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
        }

        foreach (split(/&/, $buffer)) {
                my($key, $value) = split(/=/, $_);
                $key = decodeURL($key);
                $value = decode($value);
        }

Quote:
}

sub decodeURL {
        $_ = shift;
        tr/+/ /;
        s/%(..)/pack('c', hex($1))/eg;
        return($_);

Quote:
}

/////////////////////
When the submit button is pressed, Internet Explorer brings up a
download box asking if i want to save it or open it.

What i want it to do is execute the perl script, how can i do this?

*********************
OS:            Windows 2000
Server:        Apache (latest version and auto configured for use with
perl)
Perl version:  Indigo Perl
Experiance:    Begineer
*********************



Wed, 02 Nov 2005 12:39:00 GMT  
 click submit ->starts downloading perl file......dont want it to happen
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1



Quote:
> The perl script is as follows (its a tutorial book, which im using
and
> should work with any form):

No, it doesn't.  Use the CGI.pm module that comes with Perl.  NEVER
write your own function, or copy someone else's function, for parsing
CGI data unless you're doing it as a learning exercise.  The
getFormData function that you showed has at least two bugs in it.

Quote:
> /////////////////////
> When the submit button is pressed, Internet Explorer brings up a
> download box asking if i want to save it or open it.

> What i want it to do is execute the perl script, how can i do
this?

> *********************
> OS:            Windows 2000
> Server:        Apache (latest version and auto configured for use
with
> perl)
> Perl version:  Indigo Perl
> Experiance:    Begineer
> *********************

This is a server configuration issue, not a perl issue.  You need to
tell Apache to execute the script rather than to serve it as a file
for download.  You have to make sure the CGI script is executable by
the user who is running the web server, and you need to make sure
that the Apache ExecCGI flag is turned on in the directory where the
script resides.

HTH
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13

iD8DBQE+xixfY96i4h5M0egRAq9tAKDOYxya947kycQv5wpYTa16mtwSZQCfZgL3
bfhFkPs8acTcIhQPkRBRvm0=
=Wu3e
-----END PGP SIGNATURE-----



Wed, 02 Nov 2005 13:35:27 GMT  
 click submit ->starts downloading perl file......dont want it to happen

Quote:

> i got a simple form

<snip>

Quote:
> The perl script is as follows (its a tutorial book, which im using and
> should work with any form):

That script is incomplete. Besides a couple of typos, it doesn't do
anything with the form data.

Quote:
> #!/C:/perl/bin/perl.exe

----^
Remove that slash.

The rest of the script should better look something like this:

     use strict;
     use warnings;
     use CGI::Carp 'fatalsToBrowser';
     use CGI ':standard';

     print header;
     for (param) { print "$_ = ", param($_), "<br>\n" }

Quote:
> What i want it to do is execute the perl script, how can i do this?

The above script may be executed. But you should decide what you want
the script to do, and program accordingly.

/ Gunnar

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



Wed, 02 Nov 2005 14:03:30 GMT  
 click submit ->starts downloading perl file......dont want it to happen

Quote:

> i got a simple form which looks like this:

> <form name="feedback" action="cgi-bin/feedback.pl" method="post">

[some more HTML]

Quote:
> The perl script is as follows (its a tutorial book, which im using and
> should work with any form):

> #!/C:/perl/bin/perl.exe

> my(%form);

> getFormData(/%form);

I'm almost certain that your book actually has
        getFormData(\%form);
Once you get your script to work, perl will complain about that typo.

Quote:

> # data procesing statements
[more Perl code]

> /////////////////////
> When the submit button is pressed, Internet Explorer brings up a
> download box asking if i want to save it or open it.

That most likely is an issue with the server configuration.
www.apache.org has extensive documentation that may help you.


Wed, 02 Nov 2005 14:20:54 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. click on cgi script to download file

2. click on cgi script to download file

3. Executing perl script with perl.exe wants to download file

4. Q: How to automatically start a file download in a CGI script

5. avoid double-click on submit button

6. Newbie from Intel Evil Empire wants to know how to get started with basic Perl program

7. Wanted: Perl Tutor in person - to get me started / N. Dallas

8. ?: Automatically starting a download process

9. this cgi starts download why??

10. CRLF->LF conversion happens even on Solaris

11. LWP / UserAgent problem: $form -> click

12. What happened to $fh->input_record_separator ?

 

 
Powered by phpBB® Forum Software