home *** CD-ROM | disk | FTP | other *** search
/ Web Designer 98 (Professional) / WebDesigner 1.0.iso / cgi2 / download.cgi-s=formmail&c=txt&f=readme < prev    next >
Encoding:
Text File  |  1996-06-04  |  23.2 KB  |  521 lines

  1. ##############################################################################
  2. # FormMail                        Version 1.6                                #
  3. # Copyright 1996-1997 Matt Wright mattw@worldwidemart.com                    #
  4. # Created 06/09/95                Last Modified 05/02/97                     #
  5. # Matt's Script Archive, Inc.:    http://www.worldwidemart.com/scripts/      #
  6. ##############################################################################
  7. # If you run into any problems while trying to configure this scripts, help  #
  8. # is available.  The steps you should take to get the fastest results, are:  #
  9. #       1) Read this file thoroughly.                                        #
  10. #       2) Consult the Matt's Script Archive Frequently Asked Questions:     #
  11. #               http://www.worldwidemart.com/scripts/faq/                    #
  12. #       3) If you are still having difficulty installing this script, send   #
  13. #          e-mail to: scripts-help@tahoenet.com                              #
  14. #          Include any error messages you are receiving and as much detail   #
  15. #          as you can so we can spot your problem.  Also include the variable#
  16. #          configuration block that is located at the top of the script.     #
  17. #                                                                            #
  18. # Hopefully we will be able to help you solve your problems.  Thank you.     #
  19. ##############################################################################
  20. # COPYRIGHT NOTICE                                                           #
  21. # Copyright 1995 - 1997 Matthew M. Wright  All Rights Reserved.              #
  22. #                                                                            #
  23. # FormMail may be used and modified free of charge by anyone so long as this #
  24. # copyright notice and the comments above remain intact.  By using this      #
  25. # code you agree to indemnify Matthew M. Wright from any liability that      #
  26. # might arise from its use.                                                  #
  27. #                                                                            #
  28. # Selling the code for this program without prior written consent is         #
  29. # expressly forbidden.  In other words, please ask first before you try and  #
  30. # make money off of my program.                                              #
  31. #                                                                            #
  32. # Obtain permission before redistributing this software over the Internet or #
  33. # in any other medium.    In all cases copyright and header must remain intact #
  34. ##############################################################################
  35.  
  36. FormMail is a universal WWW form to E-mail gateway.  There is only one
  37. required form input tag which must be specified in order for this script to
  38. work with your existing forms.  Other hidden configuration fields can also
  39. be used to enhance the operation of FormMail on your site.  Version 1.6 of
  40. FormMail contains a few minor bug fixes, optimized code and more comments.
  41. The biggest change in this version is that by default, form fields are now
  42. sorted as they appear in the form.  Error pages were also beautified a
  43. little and two new configuration fields were created.  Read the History for
  44. a more complete list of changes.
  45.  
  46. The script, FormMail.pl, needs to be placed in your server's cgi-bin and the 
  47. anonymous WWW user must have the ability to read/execute the script.  If 
  48. you do not have access to your server's cgi-bin, yet you can execute cgi 
  49. scripts, you may want to try adding a .cgi extension to the FormMail.pl, 
  50. so you could move it to FormMail.cgi.
  51.  
  52. Setting Up the FormMail Script:
  53. ===============================
  54.  
  55. The FormMail.pl script does not have to be extensively configured in order 
  56. to work.  There are only two variables in the perl file which you will 
  57. need to define along with changing the top line of your script to match 
  58. the location of you Perl interpreter.
  59.  
  60. Necessary Variables:
  61. --------------------
  62.  
  63.   $mailprog = '/usr/lib/sendmail';
  64.     This variable must define the location to your server's sendmail 
  65.     program.  If this is incorrect, form results will not be mailed to you.
  66.  
  67.   @referers = ('worldwidemart.com','206.31.72.203');
  68.     This array allows you to define the domains that you will allow 
  69.     forms to reside on and use your FormMail script.  If a user tries to 
  70.     put a form on another server, that is not worldwidemart.com, they 
  71.     will receive an error message when someone tries to fill out their form.
  72.     By placing worldwidemart.com in the @referers array, this also allows
  73.     www.worldwidemart.com, ftp.worldwidemart.com, any other http address
  74.     with worldwidemart.com in it and worldwidemart.com's IP address to access
  75.     this script as well, so no users will be turned away.
  76.  
  77. Your FormMail program is now configured.
  78.  
  79. -----------------------------------------------------------------------------
  80.  
  81. Form Configuration:
  82. ===================
  83.  
  84. The action of your form needs to point towards this script (obviously), and 
  85. the method must be POST or GET in capital letters.  Version 1.5 of FormMail 
  86. offers many new ways to code your form to tailor the resulting HTML page 
  87. and the way the script performs.  Below is a list of form fields you can 
  88. use and how to implement them.
  89.  
  90. Necessary Form Fields:
  91. ======================
  92.  
  93. There is only one form field that you must have in your form, for 
  94. FormMail to work correctly.  This is the recipient field.
  95.  
  96. Field:       recipient
  97.  
  98. Description: This form field allows you to specify to whom you wish for your
  99.              form results to be mailed.  Most likely you will want to
  100.              configure this option as a hidden form field with a value equal
  101.              to that of your e-mail address.
  102.  
  103. Syntax:
  104.              <input type=hidden name="recipient" value="email@your.host.com">
  105.  
  106. -----------------------------------------------------------------------------
  107.  
  108. Optional Form Fields:
  109. =====================
  110.  
  111. Field:       subject
  112.  
  113. Description: The subject field will allow you to specify the subject that you
  114.              wish to appear in the e-mail that is sent to you after this form
  115.              has been filled out.  If you do not have this option turned on,
  116.              then the script will default to a message subject: WWW Form
  117.              Submission
  118.  
  119. Syntax:
  120.              If you wish to choose what the subject is:
  121.               <input type=hidden name="subject" value="Your Subject">
  122.  
  123.              To allow the user to choose a subject:
  124.               <input type=text name="subject">
  125.  
  126. -----------------------------------------------------------------------------
  127.  
  128. Field:       email
  129.  
  130. Description: This form field will allow the user to specify their return
  131.              e-mail address.  If you want to be able to return e-mail to your
  132.              user, I strongly suggest that you include this form field and
  133.              allow them to fill it in.  This will be put into the From:
  134.              field of the message you receive.  If you want to require an
  135.              email address with valid syntax, add this field name to the
  136.              'required' field.
  137.  
  138. Syntax:
  139.              <input type=text name="email">
  140.  
  141. -----------------------------------------------------------------------------
  142.  
  143. Field:       realname
  144.  
  145. Description: The realname form field will allow the user to input their real
  146.              name.  This field is useful for identification purposes and will
  147.              also be put into the From: line of your message header.
  148.  
  149. Syntax: 
  150.              <input type=text name="realname">
  151.  
  152. -----------------------------------------------------------------------------
  153.  
  154. Field:       redirect
  155.  
  156. Description: If you wish to redirect the user to a different URL, rather than
  157.              having them see the default response to the fill-out form, you
  158.              can use this hidden variable to send them to a pre-made HTML
  159.              page.
  160.  
  161. Syntax:
  162.              To choose the URL they will end up at:
  163.                <input type=hidden name="redirect" 
  164.                                   value="http://your.host.com/to/file.html">
  165.  
  166.              To allow them to specify a URL they wish to travel to once the
  167.              form is filled out:
  168.                <input type=text name="redirect">
  169.  
  170. -----------------------------------------------------------------------------
  171.  
  172. Field:       required
  173.  
  174. Version:     1.3 & Up
  175.  
  176. Description: You can now require for certain fields in your form to be filled
  177.              in before the user can successfully submit the form.  Simply
  178.              place all field names that you want to be mandatory into this
  179.              field.  If the required fields are not filled in, the user will
  180.              be notified of what they need to fill in, and a link back to
  181.              the form they just submitted will be provided.
  182.  
  183.              To use a customized error page, see 'missing_fields_redirect'
  184.  
  185. Syntax:
  186.              If you want to require that they fill in the email and phone
  187.              fields in your form, so that you can reach them once you have
  188.              received the mail, use a syntax like:
  189.  
  190.                <input type=hidden name="required" value="email,phone">
  191.  
  192. -----------------------------------------------------------------------------
  193.  
  194. Field:       env_report
  195.  
  196. Version:     1.3 & Up
  197.  
  198. Description: Allows you to have Environment variables included in the
  199.              e-mail message you receive after a user has filled out your
  200.              form.  Useful if you wish to know what browser they were using,
  201.              what domain they were coming from or any other attributes
  202.              associated with environment variables.  The following is a short
  203.              list of valid environment variables that might be useful:
  204.  
  205.              REMOTE_HOST     - Sends the hostname making a request.
  206.              REMOTE_ADDR     - Sends the IP address of the remote host making
  207.                                the request.
  208.              REMOTE_USER     - If server supports authentication and script
  209.                                is protected, this is the username they have
  210.                                authenticated as. *This is not usually set.*
  211.              HTTP_USER_AGENT - The browser the client is using to send the
  212.                                request.  
  213.  
  214.              There are others, but these are a few of the most useful.  For
  215.              more information on environment variables, see:
  216.  
  217.             http://www.cgi-resources.com/Documentation/Environment_Variables/
  218.  
  219. Syntax:
  220.              If you wanted to find the remote host and browser sending the
  221.              request, you would put the following into your form:
  222.  
  223.               <input type=hidden name="env_report" value="REMOTE_HOST,
  224.                                                            HTTP_USER_AGENT">
  225.  
  226. -----------------------------------------------------------------------------
  227.  
  228. Field:       sort
  229.  
  230. Version:     1.4 & Up
  231.  
  232. Description: This field allows you to choose the order in which you wish 
  233.              for your variables to appear in the e-mail that FormMail
  234.              generates.  You can choose to have the field sorted
  235.              alphabetically or specify a set order in which you want the
  236.              fields to appear in your mail message.  By leaving this field
  237.              out, the order will simply default to the order in which the 
  238.              browsers sends the information to the script (which is usually
  239.              the exact same order as they appeared in the form.)  When
  240.              sorting by a set order of fields, you should include the phrase
  241.              "order:" as the first part of your value for the sort field, and
  242.              then follow that with the field names you want to be listed in
  243.              the e-mail message, separated by commas.  Version 1.6 allows a
  244.              little more flexibility in the listing of ordered fields, in
  245.              that you can include spaces and line breaks in the field without
  246.              it messing up the sort.  This is helpful when you have many form
  247.              fields and need to insert a line wrap.
  248.  
  249. Syntax:
  250.              To sort alphabetically:
  251.                <input type=hidden name="sort" value="alphabetic">
  252.  
  253.              To sort by a set field order:
  254.                <input type=hidden name="sort" value="order:name1,name2,
  255.                                                    name3,etc...">
  256.  
  257. -----------------------------------------------------------------------------
  258.  
  259. Field:       print_config
  260.  
  261. Version:     1.5 & Up
  262.  
  263. Description: print_config allows you to specify which of the config 
  264.              variables you would like to have printed in your e-mail message.
  265.              By default, no config fields are printed to your e-mail.  This
  266.              is because the important form fields, like email, subject, etc.
  267.              are included in the header of the message.  However some users
  268.              have asked for this option so they can have these fields printed
  269.              in the body of the message.  The config fields that you wish to
  270.              have printed should be in the value attribute of your input tag
  271.              separated by commas.
  272.  
  273. Syntax:
  274.              If you want to print the email and subject fields in the body of
  275.              your message, you would place the following form tag:
  276.  
  277.               <input type=hidden name="print_config" value="email,subject">
  278.  
  279. -----------------------------------------------------------------------------
  280.  
  281. Field:       print_blank_fields
  282.  
  283. Version:     1.6
  284.  
  285. Description: print_blank_fields allows you to request that all form fields
  286.              are printed in the return HTML, regardless of whether or not
  287.              they were filled in.  FormMail defaults to turning this off, so
  288.              that unused form fields aren't e-mailed.
  289.  
  290. Syntax:
  291.  
  292.              If you want to print all blank fields:
  293.               <input type=hidden name="print_blank_fields" value="1">
  294.  
  295. ----------------------------------------------------------------------------
  296.  
  297. Field:       title
  298.  
  299. Version:     1.3 & Up
  300.  
  301. Description: This form field allows you to specify the title and header that
  302.              will appear on the resulting page if you do not specify a
  303.              redirect URL.
  304.  
  305. Syntax:
  306.              If you wanted a title of 'Feedback Form Results':
  307.               <input type=hidden name="title" value="Feedback Form Results">
  308.  
  309. -----------------------------------------------------------------------------
  310.  
  311. Field:       return_link_url
  312.  
  313. Version:     1.3 & Up
  314.  
  315. Description: This field allows you to specify a URL that will appear, as
  316.              return_link_title, on the following report page.  This field
  317.              will not be used if you have the redirect field set, but it is
  318.              useful if you allow the user to receive the report on the
  319.              following page, but want to offer them a way to get back to
  320.              your main page.
  321.  
  322. Syntax:
  323.              <input type=hidden name="return_link_url" 
  324.                              value="http://your.host.com/main.html">
  325.  
  326. -----------------------------------------------------------------------------
  327.  
  328. Field:       return_link_title
  329.  
  330. Version:     1.3 & Up
  331.  
  332. Description: This is the title that will be used to link the user back to the
  333.              page you specify with return_link_url.  The two fields will be
  334.              shown on the resulting form page as:
  335.  
  336.              <ul>
  337.               <li><a href="return_link_url">return_link_title</a>
  338.              </ul>
  339.  
  340. Syntax:
  341.              <input type=hidden name="return_link_title"
  342.                                                   value="Back to Main Page">
  343.  
  344. -----------------------------------------------------------------------------
  345.  
  346. Field:       missing_fields_redirect
  347.  
  348. Version:     1.6
  349.  
  350. Description: This form field allows you to specify a URL that users will be
  351.              redirected to if there are fields listed in the required form
  352.              field that are not filled in.  This is so you can customize an
  353.              error page instead of displaying the default.
  354.  
  355. Syntax:
  356.              <input type=hidden name="missing_fields_redirect"
  357.                                     value="http://your.host.com/error.html">
  358.  
  359. -----------------------------------------------------------------------------
  360.  
  361. Field:       background
  362.  
  363. Version:     1.3 & Up
  364.  
  365. Description: This form field allow you to specify a background image that
  366.              will appear if you do not have the redirect field set.  This
  367.              image will appear as the background to the form results page.
  368.  
  369. Syntax:
  370.              <input type=hidden name="background"
  371.                                      value="http://your.host.com/image.gif">
  372.  
  373. -----------------------------------------------------------------------------
  374.  
  375. Field:       bgcolor
  376.  
  377. Version:     1.3 & Up
  378.  
  379. Description: This form field allow you to specify a bgcolor for the form
  380.              results page in much the way you specify a background image.
  381.              This field should not be set if the redirect field is.
  382.  
  383. Syntax:
  384.              For a background color of White:
  385.               <input type=hidden name="bgcolor" value="#FFFFFF">
  386.  
  387. -----------------------------------------------------------------------------
  388.  
  389. Field:       text_color
  390.  
  391. Version:     1.3 & Up
  392.  
  393. Description: This field works in the same way as bgcolor, except that it
  394.              will change the color of your text.
  395.  
  396. Syntax:
  397.              For a text color of Black:
  398.               <input type=hidden name="text_color" value="#000000">
  399.  
  400. -----------------------------------------------------------------------------
  401.  
  402. Field:       link_color
  403.  
  404. Version:     1.3 & Up
  405.  
  406. Description: Changes the color of links on the resulting page.  Works in the
  407.              same way as text_color.  Should not be defined if redirect is.
  408.  
  409. Syntax:
  410.              For a link color of Red:
  411.               <input type=hidden name="link_color" value="#FF0000">
  412.  
  413. -----------------------------------------------------------------------------
  414.  
  415. Field:       vlink_color
  416.  
  417. Version:     1.3 & Up
  418.  
  419. Description: Changes the color of visited links on the resulting page. Works
  420.              exactly the same as link_color.  Should not be set if redirect
  421.              is.
  422.  
  423. Syntax:
  424.              For a visited link color of Blue:
  425.               <input type=hidden name="vlink_color" value="#0000FF">
  426.  
  427. -----------------------------------------------------------------------------
  428.  
  429. Field:       alink_color
  430.  
  431. Version:     1.4 & Up
  432.  
  433. Description: Changes the color of active links on the resulting page. Works
  434.              exactly the same as link_color.  Should not be set if redirect
  435.              is.
  436.  
  437. Syntax:
  438.              For a visited link color of Blue:
  439.               <input type=hidden name="alink_color" value="#0000FF">
  440.  
  441. -----------------------------------------------------------------------------
  442.  
  443. Any other form fields that appear in your script will be mailed back to 
  444. you and displayed on the resulting page if you do not have the redirect 
  445. field set.  There is no limit as to how many other form fields you can 
  446. use with this form, except the limits imposed by browsers and your server.
  447.  
  448. -----------------------------------------------------------------------------
  449.  
  450. Some of the possible uses of this script are:
  451.  
  452. 1) You want to have a form that will be mailed to you, but aren't sure how to 
  453.    write the CGI script for it.
  454. 2) You are the webmaster of your site and want to allow users to use forms, 
  455.    but not to have their own cgi-bin directories, which can cause 
  456.    security risks to your system.  You can set this script up and then 
  457.    allow all users to run off of it.
  458. 3) Want to have one script to parse all of your html forms and mail them 
  459.    to you.
  460.  
  461. -----------------------------------------------------------------------------
  462.  
  463. History:
  464. Version 1.0     06/11/95  -  This script was created.
  465. Version 1.1     08/03/95  -  A major hole in the script which allowed users 
  466.                              to run commands under your server's uid was 
  467.                              disabled, thanks to Paul Phillips, who noticed
  468.                              the error.
  469.                           -  The ability to redirect the user to a specified
  470.                              HTML file after they filled out a form was 
  471.                              added.
  472. Version 1.2     09/23/95  -  If the form field is one of the required or 
  473.                              optional 'special' fields, such as redirect, 
  474.                              recipient, subject, email, realname, etc... the
  475.                              script will not print these fields to either
  476.                              your mail message or to the user's screen when
  477.                              they are returned to a generic form response.
  478.                              It helps you so that things do not get 
  479.                              duplicated.
  480. Version 1.3     01/21/96  -  Much needed update finally completed
  481.                           -  Added form fields: env_report, bgcolor, 
  482.                              background, link_color, vlink_color, title,
  483.                              text_color, return_link_title, return_link_url 
  484.                              and required.
  485.                           -  Security hole, which allowed any user on any 
  486.                              system to bum off of your FormMail script, has
  487.                              been plugged up with the @referers variable.
  488.                           -  Report style in return html and e-mail touched 
  489.                              up a bit.
  490. Version 1.4        01/23/96  -  Added options: sort, alink_color 
  491.                           -  Fixed a few bugs from Version 1.3, namely the 
  492.                              fact that the link_colors weren't working well.
  493.                           -  FormMail now supports both the GET and POST 
  494.                              methods.
  495. Version 1.5     02/05/96  -  Sorting of Fields in E-Mail Response Fixed.
  496.                           -  print_config option added.
  497. Version 1.6     05/02/97  -  Sorting of fields by default was fixed to now
  498.                              sort in the order the fields are passed to
  499.                              FormMail from the web browser, which is usually
  500.                              the same order as they appear in the HTML form.
  501.                           -  The sort order: directive, env_report and 
  502.                              print_config parsing routines were made to 
  503.                              better compensate for line breaks and extra
  504.                              spaces in input for ease of use.
  505.                           -  Redirect error causing the redirect option to
  506.                              incorrectly work with https (secure servers)
  507.                              was fixed.
  508.                           -  Input of a '0' in a regular form field now
  509.                              recognized as input and sent back to user.
  510.                           -  Output of non-filled in form fields suppressed.
  511.                           -  E-mail addresses checked for correct syntax if
  512.                              designated a required field.
  513.                           -  Fields only printed if they contain a value or
  514.                              if the print_blank_fields option is set to 1.
  515.                           -  missing_fields_redirect added so you can route
  516.                              users who don't completely fill out the form to
  517.                              a pre-made HTML page.
  518.                           -  Parts of code optimized, especially in respect
  519.                              to the way config variables are handled.
  520. -----------------------------------------------------------------------------
  521. Matt Wright - mattw@worldwidemart.com - http://www.worldwidemart.com/scripts/