Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

fundamental mod-perl start_multipart_form question

by Bruce32903 (Scribe)
on Feb 02, 2009 at 14:51 UTC ( #740714=perlquestion: print w/replies, xml ) Need Help??

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

Greetings,

I have been using books and web postings to teach myself mod-perl. I am starting to have some inconsistent problems and I need to double check to see if I have correctly figured out what I am doing wrong.

I started with one subroutine doing "common stuff" and posting appropriate text/controls to the html page. I then did a context dependent jump to one of several subroutines to do more tasks and make additional postings to the html page. This seems to be wrong.

My questions are:

1) Am I correct that all printing to the html page must be done within a SINGLE start_multipart_form and its matching end_form? (I was not doing this)

2) Am I correct that I should be able to have more than one submit button in that form? (so far only one button has worked)

3) Am I free to use plain old print statements above and below the form code, or do I need to have all writing to the html page done within the form? (I have used prints above and below multiple forms and I'm starting to think that this is wrong)

Thank you,
Bruce


=== UPDATE===

Thank you to all who responded. I'll read the suggested link and put to use the suggestions/comments. I should be able to get a little farther now.

Thank you,
Bruce
  • Comment on fundamental mod-perl start_multipart_form question

Replies are listed 'Best First'.
Re: fundamental mod-perl start_multipart_form question
by bassplayer (Monsignor) on Feb 02, 2009 at 15:55 UTC

    Bruce,

    You would receive better answers if you post code. An HTML form is one element in an HTML page. You can have many (this page does, for me), and you can have much HTML in and around them. They can have multiple submit buttons. So your answers would be 1: NO, 2: YES, 3: YES. That said, it really depends on how you are generating your HTML. There are things that could make what I say untrue with respect to your interface (CGI.pm, for instance), though I suspect these things should generally remain true. :-)

    Update: Guessing this is CGI::Application, but what I said should still hold true. Personally, I prefer keeping the HTML (presentation layer) separated from the code, but perhaps that's a separate discussion.

    bassplayer

      Yes, I am using Perl with "use CGI qw( :standard escapeHTML);" and "use DBI;". I usually rewrite a small program with the code targeted to my question. But in this case I'm currently only asking the fundamental "only one form" and "must all prints be inside the form" questions. If my program architecture is way off in left field then it needs rewritten rather than debugged. Posting code might only add fog to my direct and to the point question.

      I'm still a bit confused by the "yes" to multiple forms issue. The "Perl In A Nutshell" book indicates that start_multipart_form generates <html> and <body> tags. Shouldn't I only have one set of <html> and <body> tags in a single html page?

      Thanks,
      Bruce
        Your questions are really about CGI.pm and HTML, not about mod_perl. There is good documentation for CGI.pm that should help you. It doesn't look to me like start_multipart_form() prints html and body tags.

        perrin offers sound advice.

        To clarify, my answers were HTML answers. You can have many forms in a web page. CGI.pm is my preferred module for reading CGI form parameters, but I do not use it to create HTML. Although it doesn't seem to, if start_multipart_form indeed generates <html> and <body> tags, then the answer would be no, since only one of each are allowed. Your browser may be displaying it, but not all will reliably. Good luck!

        bassplayer

Log In?
Username:
Password:

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

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



    Results (162 votes). Check out past polls.

    Notices?