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?