Current location: Hot Scripts Forums » Programming Languages » Perl » Cookie sub format_input messing up help pretty plzzz


Cookie sub format_input messing up help pretty plzzz

Reply
  #1 (permalink)  
Old 08-04-11, 08:04 AM
waterw1 waterw1 is offline
New Member
 
Join Date: Jul 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
X_X Cookie sub format_input messing up help pretty plzzz

ok when i view the website and hit submit without putting anything in name i get this:
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:





Please return to the form complete name.


my cgi code is:

#!C:/Perl/bin/perl.exe
#c11ex1b.cgi - displays a Web page containing the user's
#name and the book information
use CGI qw(:standard -debug);

#prevent Perl from creating undeclared variables
use strict;

#declare variables
my ($name, $C_name, $data_ok, $msg);

#assign input to variable
$name = param('Name');
$C_name = param('C_Name');

($name, $C_name) = format_input();
($data_ok, $msg) = validate_input();
if ($data_ok eq "N") {
create_error_page();
}
else {
create_cookie();
}

exit;

#*****user-defined functions*****
sub format_input {
my ($n, $e);
($n) = ($name);
#remove leading and trailing spaces from name
$n =~ s/^ +//;
$n =~ s/ +$//;
return $n;
} #end format_input

sub validate_input {
my ($valid, $errormsg);
$valid = "Y";
if ($name eq "") {
$valid = "N";
$errormsg = "complete name";
}
return $valid, $errormsg;
} #end validate_input

sub create_error_page {
print "<HTML>\n";
print "<HEAD><TITLE>Jubilee Book Club</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H2>Please return to the form $msg.</H2>\n";
print "</BODY></HTML>\n";
} #end create_error_page

sub create_cookie {
#create cookie
$C_name = cookie(-name => "Name",
-value => "$name",
-path => "/cgi-bin/chap11",
-expires => "+6M");

#send cookie to browser
print header(-coookie => $C_name);

#create Web page
print "<HTML>\n";
print "<HEAD><TITLE>Jubilee Book Club</TITLE></HEAD>\n";
print "<BODY>\n";
print "<H1 ALIGN=center>Hello, $name!<BR>\n";
print "The book of the month is</H1><HR>\n";
print "<H2 ALIGN=center><FONT COLOR=red>\n";
print "<I>The Case of the Missing Dagger</I>\n";
print "<BR>by H.T. Sims\n";
print "</FONT></H2>\n";
print "</BODY></HTML>\n";
}


lol need some help im a noob at perl/cgi. thanks to all who reply. anything wrong with my sub format input? or the cgi code?
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
access cookie from different path crmpicco JavaScript 1 02-21-06 03:03 PM
maintaing state with a server Betty Perl 0 12-09-05 07:23 AM
Setting a cooke (time it expires) mcrob PHP 4 04-27-05 12:13 PM
Passing info between pages w/ URL HairySpider JavaScript 6 01-09-05 08:47 AM


All times are GMT -5. The time now is 04:57 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.