Category: | CGI programming. |
Author/Contact Info | DigitalKitty |
Description: | Stores web form data in a file for later analysis. I am planning on a few improvements ( such as checking form entries for correct input type, etc. ) in the near future. |
#!/usr/bin/perl -wT print "Content-type: text/html\n\n"; use CGI; #Import CGI module. use CGI::Carp qw( fatalsToBrowser ); use strict; #Use the strict pragma. #Declare variables. my ( @array,$f_name, $f_reason, $f_email, $f_areacode, $f_exchange,$f_ +pnumber,$f_response,$f_urgent,$f_textarea ); my $q = new CGI; #Create new object reference for CGI. $f_name = $q->param("f_name"); #Assign form vars to variables. $f_reason = $q->param("f_reason"); $f_email = $q->param("f_email"); $f_areacode = $q->param("f_areacode"); $f_exchange = $q->param("f_exchange"); $f_pnumber = $q->param("f_pnumber"); $f_response = $q->param("f_response"); $f_urgent = $q->param("f_urgent"); $f_textarea = $q->param("f_textarea"); #Place form data in an array. @array = ("$f_name", "$f_reason", "$f_email", "$f_areacode $f_exchange + $f_pnumber", "$f_response", "$f_urgent", "$f_textarea", "\n"); #Open the file feedback.txt for appending. open(FH, ">>feedback.txt") or die "Couldn't open file: $!\n"; foreach (@array) #Iterate over the array printing all field in the fil +e. { print FH "$_\n"; } close FH; #Close the file. print <<EOF; #Beginning of 'here' document. Displays message to custo +mer. <HTML> <HEAD> <TITLE> </TITLE> </HEAD> <BODY> <H4>Thank You. You will be contacted by $f_response shortly.</H4> </BODY> </HTML> EOF #End of 'here' document. |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Simple Feedback form.
by particle (Vicar) on Mar 25, 2002 at 14:06 UTC |