Click to See Complete Forum and Search --> : Reading Form data and displaying has HTML


p5r79
10-27-2005, 09:13 PM
I've been messing around with this trying to make it work but I'm not having any luck. Can someone please tell me what's wrong?
The first set of codes are for the form.
The second set of codes are my attempt at reading the data and displaying the result as a HTML document.
Thank you!
-----------form----------------
#!/usr/local/bin/perl -wT
use strict;
use CGI qw(:standard);


print header,
start_html(-title=>'Form',-BGCOLOR=>'#EDEDCE'),
h2('Assignment 2.2 Form'),
start_form( { -action => "results.pl",
-enctype => "application/x-www-form-urlencoded",
-method => "post" } ),

"Please, enter your name in two or more words. ",
p,
radio_group(-name=>'suffix',
-values=>['Mr.','Ms.','Dr.'],
-default=>'Mr.'),
textfield(-name=>'name',-size=>50,-maxlength=>80),
p,
"I am feeling ",
popup_menu(-name=>'feelings',
-values=>['Sleepy','Happy','Angry','Sad'],-default=>'Sad'),
p,
"The reason for my feeling this way is probably because: ",
p,
textarea(-name=>'reason',-rows=>5,-columns=>50),
p,
"I will now better do the following: ",


checkbox_group(-name=>'actions',
-values=>['Drive my car','Go see a movie','Go to the beach','Go to sleep']),
p,
p( input( { -type => "submit",
-value => "Submit"} ),
" ",
input( { -type => "reset"} ),
), # end p
end_form,
end_html;

--------------result HTML---------------------

#!/usr/local/bin/perl -Tw
use strict;
use CGI;


my $suffix = param('suffix');
my $name = param('name');
#$feelings = param('feelings');
#$reason = param('reason');
#$actions = param('actions');


print header,
start_html(-title=>'Results',-BGCOLOR=>'#EDEDCE',-target=>'_blank'),
h2('Assignment 2.2 Form Results'),p,
"My name is ",em($suffix," "),em($name,"."),p,
# "I am feeling ",em(param('feelings'),"."),p,
# "The reason why I feel ",em(param('feelings')," "), "is probably because ",em(param('reason'),"."),p,
# "I better ",em(join(", ",param('actions'))),".\n";

end_html;

Ultimater
10-27-2005, 09:28 PM
On your second page use:

use CGI qw(:standard);

instead of:

use CGI;

p5r79
10-28-2005, 10:46 AM
Thank you!!!!! It worked!!!!