Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Simple Feedback form.

by DigitalKitty (Parson)
on Mar 25, 2002 at 04:13 UTC ( #154017=sourcecode: print w/ replies, xml ) Need Help??

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.

Comment on Simple Feedback form.
Download Code
Re: Simple Feedback form.
by particle (Vicar) on Mar 25, 2002 at 14:06 UTC
    or for those of you who like CGI's html generation capabilities,
    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.
    becomes
    print $q->header, $q->start_html, $q->h4("Thank You. You will be contacted by $f_response shortly.") +, $q->end_html;
    on the whole, this code could use some re-working. it's a good first effort, but read Ovid's Web Programming Using Perl Course. it's brilliant. you'll learn a lot.

    ~Particle ;

Back to Code Catacombs

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: sourcecode [id://154017]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-07-13 19:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (251 votes), past polls