} # Display error if username or password fields are left blank if($user_name eq "" || $password eq "") { &error(); } else { #check if the user name and password are in the database $sth = $db->prepare(q{SELECT user_id, password from user where user_id = ?}) $sth->execute($user_name) while(@row = $sth->fetchrow_array){ if($user_name eq $row[0] && $password eq $row[1]) { #go to main page } else { # If the username or password are not in the database if($user_name ne $row[0] || $password ne $row[1]) { &error(); }