in reply to Re: Debugging a login script using MySQL
in thread Debugging a login script using MySQL

I can't find them, to tell you the truth. I'm on a new webhost I haven't been with before and I'm just getting used to Cpanel XP.

I did make progress by modifing to the code below. It doesn't kill the script now (who knows why) but it doesn't sign in either. By adding the print header line the 500 error is gone but it doesn't say the login was successfull or the login failed. So I'm thinking it has something to do with the database lines.

Anyone have any ideas?

else { print "Content-type: text/html\n\n"; use CGI::Carp qw(fatalsToBrowser); print "test<br><br>"; #exit; $username = (param('form_user')); $userpass = (param('form_pass')); $userpass = md5_hex($userpass); #check the database my $dbh = DBI->connect("DBI:mysql:$edt_dbase", $mysql_user, $m +ysql_pass) or print DBI->errstr; my $sth = $dbh->prepare("SELECT * FROM $users_table WHERE user +name = '$username' AND user_password = '$userpass'"); $sth->execute; print "test 2"; 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; }

Replies are listed 'Best First'.
Re^3: Debugging a login script using MySQL
by Thilosophy (Curate) on Jan 05, 2005 at 05:11 UTC
    By adding the print header line the 500 error is gone but it doesn't say the login was successfull or the login failed.

    So, what does it say now? Just "test" or also "test 2". If something is wrong with the DB, there should be no "test 2". The use CGI::Carp qw(fatalsToBrowser); should print any error messages to your browser. Does it?

      Right now it says both test and test 2. But that's it. It prints both my test messages but doesn't appear to even attempt to log in.

      I am not a MySQL expert but if I don't have data in the tables username and user_password, could it be the problem? I set up the tables but I don't know how to setup the rows properly so I don't think either contain any data.

      That's the only idea I have to go about fixing this. And as for your other post, yes I want to use this. The login isn't to anything secure and after I get it to finally work, I can improve it.

      Thanks.