#!/usr/bin/perl -w
use strict;

=pod

   AUTHOR
      Tommy Butler <tommy @ atrixnet.com>
      phone: (817)-468-7716
      6711 Forest Park Dr
      Arlington, TX
           76001-8403

   COPYRIGHT   Tommy Butler. All rights reserved
   LISCENCE    This software is free, use/distribute under the GNU GPL.
   BUGS TO     Tommy Butler <perlmod @ atrixnet.com>

   INSTALLATION (2 easy steps)

   1. Place this script in your cgi bin directory.

   2. Change permissions on this script to 755 on linux/unix systems
      by using your FTP client software, or from a command line shell
      by typing the following command after entering the directory where
      this script is located:
         chmod -v 755 [ script name ]

   NOTE- You can find more free Perl code at The ooOPps Open Source
         Code Library  <URL: http://ooopps.sourceforge.net/pub/>

=cut

++$|;

use CGI qw( header param );

my($token) = qr/\Q%%%\E(.*?)\Q%%%\E/;
my($form)  = &form();

if (param('reset')) {

   $form =~ s/$token//g;
}
else {

   $form =~ s/$token/param($1)||''/ge;
}

print(header, $form);


sub form { <<__HTML__ }
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html
xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en"
lang="en">
   <head>
      <title>Simple Perl CGI Form</title>
      <meta
       http-equiv="Content-Type"
       content="text/html; charset=ISO-8859-1" />
      <style
       type="text/css"
       xml:space="preserve">
         <!--

            HTML  {
               color: #000000; background-color: #FFFFFF;
               font-family: Verdana, sans-serif; font-size: 10pt;
            }

         -->
      </style>
   </head>
   <body>
      <div class="copy">
         <div>&#160;</div>
         <div>
            <h2>Welcome %%%NAME%%%</h2>
            <div>&#160;</div>
            <div style="padding: 0 0 0 20px;">
               <form method="POST">
               <table
                cellspacing="1"
                cellpadding="2"
                border="0">
                  <tr>
                     <td
                      width="200"
                      class="small">Your Name &#160;</td>
                     <td><input
                      type="text"
                      name="NAME"
                      value="%%%NAME%%%"
                      size="25" /></td>
                  </tr>
                  <tr>
                     <td
                      width="200"
                      class="small">Your Favorite Fruit &#160;</td>
                     <td><input
                      type="text"
                      name="FRUIT"
                      value="%%%FRUIT%%%"
                      size="25" /></td>
                  </tr>
                  <tr>
                     <td
                      width="200"
                      class="small">Your Favorite Color &#160;</td>
                     <td><input
                      type="text"
                      name="COLOR"
                      value="%%%COLOR%%%"
                      size="25" /></td>
                  </tr>
                  <tr>
                     <td
                      width="200"
                      class="small">Your Favorite Animal &#160;</td>
                     <td><input
                      type="text"
                      name="ANIMAL"
                      value="%%%ANIMAL%%%"
                      size="25" /></td>
                  </tr>
                  <tr>
                     <td
                      width="200"
                      class="small">Your Favorite Website &#160;</td>
                     <td><input
                      type="text"
                      name="WEBSITE"
                      value="%%%WEBSITE%%%"
                      size="25" /></td>
                  </tr>
               </table>
               <br />
               <input
                type="submit"
                name="submit"
                value="submit form" /> &#160;
               <input
                type="submit"
                name="reset"
                value="reset form" />
               </form>
            </div>
         </div>
         <p>&#160;</p>
      </div>
   </body>
</html>
__HTML__