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

I'm new at CGI. I know just enough to be dangerous. I want to let a script process form input from a HTML page web user, to post to another predesigned HTML web page so that they can update their own page; for example, I am designing an advertising page, with features spots on a page (just like in newspaper print). Can I use cgi to process their input into predesignated fields on this page. Can you point me in the right direction to what I need to learn? Thank you
  • Comment on Form to let web user input their own data to another page

Replies are listed 'Best First'.
Re: Form to let web user input their own data to another page
by Daddio (Chaplain) on Apr 22, 2001 at 00:46 UTC

    If this form's data is to be used only on the next page, and not in the future, then CGI.pm is all you will probably need.

    If, however, you intend this data to be used for more than just one post to a page, you will need to look into a method of saving the data to a file or database, and then reading it back.

    CGI.pm will do the saving to a FILEHANDLE for you, but designing a good text or relational database would probably be a better way to go.

    For TEXT database use, from what I have seen here, Text::CSV and Text::xSV seem to be the modules of choice.

    For RELATIONAL database use, DBI.pm is what I use with a MySQL database on Linux.

    So, those modules, combined with what you find here on PerlMonks will get you there. Good Luck!

      The best source of CGI info is on the perl.com website- follow the "How do I write CGI scripts?" link. As usual the best way to learn is to practice a few scripts.

      Also, if you are entering a lot of data you might want to include some simple javascript to check the information before sending to the server. I have found this to be a useful tool. There is tonnes of info for this on the web and will make the CGI stuff simpler, since you know exactly what ranges of values you will be receiving.

      It seems much more difficult than it actually is! Good Luck.

        JavaScript validation can help tremendously. Just don't rely on it.
        The reason being that folks can turn off JavaScript in their browsers. This will allow the form to be posted without the JavaScript validation.

        Hence you'll still need to do some field validation as the cgi script accepts the data.
        Claude

Re: Form to let web user input their own data to another page
by Chady (Priest) on Apr 21, 2001 at 23:44 UTC

    head on to CPAN and take a look at CGI.pm, it's all you need


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
Re: Form to let web user input their own data to another page
by $code or die (Deacon) on Apr 23, 2001 at 05:44 UTC
    Hi mrsym2

    From my understanding of your question, you want probably to do something along these lines:
    1. Process input from a form - use CGI
    2. Store the input in some sort of database (flatfile or not) - see DBI or A CSV Module
    3. Use a Template system to display data in "fields" in the advertising page. - See HTML::Template or Template Toolkit
    To summarize - using a template module makes it easy for you to seperate code and design - which is good for a lot of reasons, one of which is that it is easy for you to update the design if you have only one template to update.

    Once you have those three types of modules licked (CGI, database and templates), you find it much easier to write extendable CGI programs. Good luck in your learning,

    $code or die
    $ perldoc perldoc
      Thanks, your answer sounds like the best match for what I need to do. Could I call on you again if I problems?
Re: Form to let web user input their own data to another page
by belize (Deacon) on Apr 22, 2001 at 20:03 UTC
    There are also a number of pre-written freeware/shareware scripts that can be bought/used that you can then modify. This is a great way to "wet your feet" in Perl. You can start at:

    CGI Resources
    Free Perl Code
    Hot Scripts
    CGI Directory

    I'm sure there are more, but you should be able to find something starting with these.

    Please read some of the warnings on PerlMonks concerning these boiler-plate scripts in terms of security, efficiency, etc.

    Also take careful note of any copyright issues.

    Also try:

    Finding scripts
    Finding secure scripts