Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Hello Monks, I've been learning Perl for the past month or so, and have decided to reinforce my understanding (and add to it!) buy using CGI::Application to create a very basic forum (only single level posts, no replies, no user accounts, etc). Everything has been going great up to this point, but I've hit a road block: I'm unsure of the best practice when it comes to validating form input, and issues with fitting it into the CGI::Application MVC paradigm. At first, I had an if, else statement in my 'newpost' runmode that would check to see if the user had entered any information. If they had not yet entered information, the HTML::Template page that has the form on it would be displayed. I had the submit button on that form call the 'newpost' runmode, expecting that since the user had just entered information, the code in my else statement would be executed (in the else statement I wrote to the DB and then wanted to redirect to the 'viewall' posts runmode). After fiddling around with that, I couldn't get it working how I imagined. I then created a new runmode called 'process' that would be called upon submission of the form. However, I recall reading in the CGI::Application documentation that all runmodes should return some kind of output (html). I know I could just write another external script to validate the form, but to me that's getting away from the "all code in one place" idea that CGI::Application seems to promote. Any ideas how I should go about approaching this? Thanks for your time!


In reply to Form validation and best practice in CGI::Application by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-26 01:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found