Something like this, only a more advanced form fields module might be better if you're doing a professional app rather than a quick hack, and you'd want to put your site design in a template file rather than just hard-coding it here.
#!/usr/bin/perl use CGI qw(:standard); use strict; use warnings; my (@errors, %data, %forms); ### Validate fields if (param('submitted')) { $data{$_} = param($_) for param(); ### Do whatever convertions on %data push @errors, 'My field is required.' if !$data{'myfield'}; } ### Process form data somehow if (param('submitted') && $#errors == -1) { ### Do something, like submit to database or display result ### Forward to another page, or display form again by just ### letting it run through to the bottom } ### Generate form fields, filling in previous values $forms{'myfield'} = textfield(-name => 'myfield', -value => $data{'myf +ield'}, -size => 10, -maxlength => 50); print qq| <html> <head> <title>Page Title</title> </head> <body bgcolor="#FFFFFF"> <b>Page Title</b><p> |; if ($#errors != -1) { print '<font color="#CC0000"><b>'; print join "<br>\n", @errors; print '</b></font><p>'; } print qq| <form method="post" action="$ENV{'REQUEST_URI'}"> <input type="hidden" name="submitted" value="1"> $forms{'myfield'} <input type="submit" value="Submit"> </form> </body> </html> |;

In reply to Re: How to run scripts on the web filling out forms? by TJPride
in thread How to run scripts on the web filling out forms? 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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.