#!/usr/bin/perl -w use CGI; use strict; # Change $resultsFile to point to a file that is writeable by the webserver # Change $redirectTo to the page you wish the visitor to see after submission # Change $responseField to be the form field you wish to collect as the result my $resultsFile = '/path/to/resultsfile.xls'; my $redirectTo = 'http://domain.com/page.htm' my $responseField = 'html_field_name'; ## NOTHING BELOW HERE REQUIRES CHANGING ## my $query = new CGI; # get results from response, and assign to a variable my $entry = $query->param($responseField); my $fname = $query->param('fname'); my $lname = $query->param('lname'); my $email = $query->param('email'); # check that the results file is accessible if (!open (RESULTS, ">>$resultsFile")) { print "Content-type: text/plain\n\nERROR: Unable to open file for storing results!"; exit 0; } # replace tabs and newlines in the response with a space $entry =~ s/[\n][\t][\r]/ /gi; # create the output string, and write to the output file my $resultString = "$entry\t$fname\t$lname\t$email\n"; print RESULTS $resultString; close RESULTS; # Finished storing results, redirect to thank you page print "Location: $redirectTo\n\n";