eireanacht
Programmer
I have a small CGI script which had been working, but now does not. It is now telling me my user input is blank when in fact it is not. It now does not seem to detect values in my $in{'guestname'} or my $in{'guestcomments'} when there is in fact a value. Is there a better method for testing string data from a form?
Here is my code:
Any help is greatly appreciated!
Here is my code:
Code:
use CGI::Carp qw(fatalsToBrowser);
#!/usr/bin/perl
require "cgi-lib.pl";
&ReadParse;
$brdaddys = "$ENV{'DOCUMENT_ROOT'}/[URL unfurl="true"]www/datafile/somemail.txt";[/URL]
$mailprog="/usr/lib/sendmail";
print "Content-type: text/html\n\n";
unless (-e $mailprog)
{
print "<html><body>";
print "<h3>Can not find $mailprog.</h3>";
print "<p>There is a typo in the mail program path.</p>";
print "</body></html>";
exit(0);
}
if (($in{'guestname'} eq "") || ($in{'guestcomments'} eq ""))
{
print <<"PrintTag";
<html><body>
<h2>Guest Form Incomplete</h2>
<p>Your request to post a message to the board has been rejected due to insufficient information. To properly send your comments, please fill out:</p>
<ul>
PrintTag
if ($in{'guestname'} eq "")
{
print "\n<li> Your Name\n";
}
if ($in{'guestcomments'} eq "")
{
print "\n<li> Your comments\n";
}
print "</ul>\n</p>\n</body>\n</html>\n";
exit(0);
}
print "<html><head>";
print "<title>Thank You</title>";
print "</head>";
print "<body bgcolor=\"FF9933\" text=\"black\">";
print "<h2>Thanks for taking the time to leave a comment!</h2>";
print "Your comments have been sent to the Board Members and will be shared ";
print "on our Guest Book for our members and other guests to see.";
print "Click <a href=\"[URL unfurl="true"]http://www.falsedomain.org\"[/URL] target=\"_top\">here</a> to return to our home pages.";
print "</body></html>";
open(FILE,"$brdaddys") || die "Can't find $brdaddys.\n";
@indata = <FILE>;
close(FILE);
foreach $i (@indata)
{
#remove hard return from each record
chop($i);
($outmail) = ($i);
open (MAIL, "|$mailprog -t") || die "Can't open mail program\n";
print MAIL "To: $outmail\n";
print MAIL "From: $in{'frmaddy'}\n";
print MAIL "Subject: Comments left on the Guest Book\n\n";
print MAIL "Review and Post ASAP\n";
print MAIL "Guest Name:\n";
print MAIL "$in{'guestname'}\n\n";
print MAIL "Guest email address:\n";
print MAIL "$in{'guestemail'}\n\n";
print MAIL "Guest favorite website:\n";
print MAIL "$in{'guesturl'}\n\n";
print MAIL "Guest Comments:\n";
print MAIL "$in{'guestcomments'}\n";
close(MAIL);
}
Any help is greatly appreciated!