in reply to have cgi send data back to form on error

How is the HTML form being generated initially? You don't show us what you're redirecting it back to. If that page is generated with CGI.pm's HTML generation methods, then the form inputs will be automatically pre-filled with the values you pass to that script, assuming the names match. Otherwise, if for example it's a static HTML page, you will have to do it yourself. Take the HTML you have and turn it into a template, using perhaps HTML::Template or the Template Toolkit. Each place you have an input tag or textarea, put in the appropriate template tag to fill in the value. Then from your CGI script, invoke the template passing in the form values. The docs for the modules I mentioned give plenty of examples.

  • Comment on Re: have cgi send data back to form on error

Replies are listed 'Best First'.
Re^2: have cgi send data back to form on error
by boat73 (Scribe) on Feb 11, 2005 at 04:43 UTC
    The HTML is being generated with frontpage. I use frontpage because I admit the gui (ouch) is easy to use and quick to make changes. I feel so ashamed. I have not realy generated HTML with CGI.pm just using print <<ENDHTML but maybe I will have to look into it. The template idea has potential also but still a little more work to modify than with frontpage. Thanks for the direction.
      print <<ENDHTML can work here as well. Since Perl interpolates strings, just stick the variables you want in the appropriate places like:
      use HTML::Entities; my $email = $q->param('email'); $email = encode_entities($email); print <<ENDHTML; <input type="text" name="email" value="$email"> ENDHTML