I have a script which is supposed to e-mail a user their username/password info as long as their e-mail address is in the database. The following code works if the address is in the database (it prints the approval page and sends the mail with the correct information), but if the address is -not- in the database I get a 500 error.
Error logs say "premature end of script headers," and if I use the die statement and send fatalsToBrowser, I can see that it's dying at the 'next' statement. The question is why. I'm doing exactly the same thing in another script, and that one works. I also know that if I comment out the 'next' directive and evaluate the results of the SELECT statement, it is always selecting the e-mail address from the first table row and going no further. So if I chose the first e-mail address, it would go through, but any other entered addresses obviously don't match the address in the first row. Can anyone help me figure out what I'm doing wrong here? #!/usr/bin/perl use strict; use CGI qw(:all); use CGI::Carp qw(fatalsToBrowser); use DBI; require Mail::Send; my $q = new CGI; my $email = $q->param('forgotten_password_email'); my $dbh = DBI->connect("DBI:mysql:credmgr_usbz:localhost","credmgr","lyR1c978") or die "Database error: $!"; my $statement = <<END_OF_STATEMENT; SELECT EmailAddress,UserName,UserPass FROM UserData END_OF_STATEMENT my $sth = $dbh->prepare($statement) or die "Could not prepare statement: $!"; $sth->execute or die "Could not execute statement: $!"; my $useremail = ""; my $username = ""; my $userpass = ""; while(($useremail,$username,$userpass) = $sth->fetchrow_array) { next unless($email eq $useremail) or die "Couldn\'t \"next\" here: $!"; if($email eq $useremail) { &print_header; &print_approval; &send_subscriber_mail; &print_footer; exit; } else { &print_header; &print_denial; &print_footer; exit; } } $dbh->disconnect; # These are the routines but I'll spare you # the huge HTML here docs # sub print_header # sub print_footer # sub print_approval # sub print_denial # sub send_subscriber_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]