Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
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 examining the Monastery: (10)
As of 2015-06-02 23:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What kind of chocolate gives you the most pleasure?















    Results (116 votes), past polls