#!/usr/local/bin/perl # +-------------------------------------------+ # | MiniDB.cgi -- A mini database script to | # | takes fields passed to it | # | and write them to a file | # | | # | Author : Ryan William Facer | # | Created On : Monday August 10, 1998 | # | Last Modified By : Ryan William Facer | # | Last Modified On : Monday August 10, 1998 | # | Update Count : 0 | # | E-Mail : cattails@cattails.ca | # +------------------------------------------+ # ************************************************************************** # You must modify this variable if you want to have a different filename or # place it in a different directory. The file must be writeable so make sure # either the directory is writeable (not recommended) or create a blank file # by this name and then do 'chmod file.txt 777' or give it full permission # using the FTP program. (The >> MUST go before the filename. It signifies # that the file is to be opened and that data will be appended to it. # ************************************************************************** $file = '>>MiniDB.txt'; # ******************************* # We include the cgi-lib.cgi file # ******************************* do "cgi-lib.cgi" || die "Content-type: text/plain\n\nError loading cgi-lib\n"; # ************************************************* # Now we call the subroutine in cgi-lib.cgi to read # in the variables from the form and set them up as # 'key'='value' pairs in the array @in # ************************************************* &ReadParse; # *********************************** # Now we just write all the fields to # the file that was specified earlier # *********************************** open(FILE,"$file"); # Open the file for writing # ************************************ # We iterate through the @in array and # print everything we see to the file # ************************************ foreach $pair (@in){ ($name, $value) = split(/=/, $pair); print FILE "$value,"; }; # foreach print FILE "\n"; # Add a newline when we're all done close (FILE); # All done # ***************************************** # Print out the beginning stuff to tell the # server that we're sending it an HTML file # ***************************************** print "Content-type: text/html\n\n"; # ***************************************** # Print out the HTML page that will be seen # ***************************************** print "\n"; print "Thank You For Filling Out Our Survey\n"; print "\n\n"; print "

Your entry for the survery has been recorded. Thanks for taking\n"; print "the time to fill it out.

\n"; print "\n"; print "\n";