Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help testing for string values in CGI Mail program 1

Status
Not open for further replies.

eireanacht

Programmer
Jul 13, 2004
15
US
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:
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!
 
post your readparse sub, it's more than likely an error in there.

HTH
--Paul

Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
PaulTEG, thanks for responding. For some reason, unknown to me, the script began working as it should have done in the first place. I've reviewed the coding and can find no mistakes that would have caused the problem in the first place, which makes the fact that it is now working much more mysterious. My ReadParse has been in place for two years without problem, so I doubt that the problem was there. More likely, I'm now thinking, the issue was server/host related.

In any event, it works now and I really do appreciate you helping.
 
no worries
--Paul

Nancy Griffith - songstress extraordinaire,
and composer of the snipers anthem "From a distance ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top