I added the print "Content-type" that's commented out to see if that would fix the problem. By removing the #, it no longer errors out but produces a blank screen instead.
My original thought is it must be a database problem but even my database syntax has fail safe error responses. So now I'm really stuck. I either get a blank screen or a premature end of script header error.
Can someone take a guess at what's wrong?
else { # print "Content-type: text/html\n\n"; use CGI::Carp qw(fatalsToBrowser); $username = (param('form_user')); $userpass = (param('form_pass')); $userpass = md5_hex($userpass); #check the database my $dbh = DBI->connect("DBI:mysql:$dbase", $mysql_user, $mysql +_pass) or print DBI->errstr; my $sth = $dbh->prepare("SELECT * FROM $users_table WHERE user +name = '$username' AND user_password = '$userpass'"); $sth->execute; if ($sth->rows < 1) { print "Content-type: text/html\n\n"; print "Login information incorrect."; $dbh->disconnect; print "<script>window.location = 'login.cgi';</script>\n"; exit; } else { while ($data = $sth->fetchrow_hashref) { $u_id = $$data{"user_id"}; my $auth_user = new CGI::Cookie(-name => + 'user_id', -value => + $u_id); my $auth_pass = new CGI::Cookie(-name => + 'user_pass', -value => + $userpass); #$cookieset = $auth_user . ";" . $auth_pass; print "Set-Cookie: $auth_user\n"; print "Set-Cookie: $auth_pass\n"; print "Content-type: text/html\n\n"; print "Welcome " . $username . ", you have successfull +y logged in.\n"; print "$u_id = UID"; print "<script>window.location = 'index.cgi';</script> +\n"; } } $dbh->disconnect;
In reply to Premature end of script headers issue by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |