Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Why is my CGI.pm script trying to assign data before pressing submit.

by Purdy (Hermit)
on Dec 07, 2001 at 03:11 UTC ( #130105=note: print w/replies, xml ) Need Help??


in reply to Why is my CGI.pm script trying to assign data before pressing submit.

It sounds like you have both snippets of code in the same script, in which case, your program logic is a bit off (the user isn't given a chance to supply the filename). What I usually do in this type of situation is use hidden fields. I'm not sure offhand how to do that with CGI.pm, but something like so:

print '<INPUT TYPE="HIDDEN" NAME="PROCESS" VALUE="PARTTWO"><BR>';

Then in your script, you check if the script is being processed for someone that is just coming to your program for the first time or if they hit submit and using your program to process their input.

if ( param('PROCESS') ) { # They're using your form to process their input... # Now you can check if the filename is given if (!defined($report)) { die ...; } } else { # They're using your program for the first time print "7.) What do you want to name ..."; }

HTH,

Jason

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://130105]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2019-11-18 12:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (90 votes). Check out past polls.

    Notices?