Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9272801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:57:01+00:00 2026-06-18T15:57:01+00:00

I have login page that controle username and password. I want that when admin

  • 0

I have login page that controle username and password.

I want that when admin is selected in combobox, then program should compare given username and password with first line in my “LoginInformation.txt” file.

And when user is selected in combobox and, then program should compare given username and pasword with second line in “LoginInformation.txt” file.

But,my code doesn’t work correctly!

public class LoginFrame extends javax.swing.JFrame {

private String username;
private char[] Password;
private void LoginButtonActionPerformed(java.awt.event.ActionEvent evt) {

        username=String.valueOf(jTextField1.getText());
        Password=jPasswordField1.getPassword();

        if(jComboBox1.getSelectedIndex() == 0){
            if(adminCanGoNext()) {
              goAdminMainPage();
          }
           else{
                ErrorMessageLabel.setText("Did Not Match");
            }
        }


        else if(jComboBox1.getSelectedIndex() == 1){
            if(userCanGoNext()){
                goUserMainPage();
            }
        }



public boolean adminCanGoNext() throws IOException{
    FileReader fr=new FileReader("LoginInformation.txt");
    BufferedReader br=new BufferedReader(fr);
    String line;
    while((line=br.readLine()) != null){
        String[] infos=line.split("     ");
        String value=infos[0];
        String usern=infos[1];
        String pass=infos[2];

        if(usern.equals(username.trim()) && pass.equals(String.valueOf(Password))){
            return true;
        }
    }
    return false;
}

public void goAdminMainPage() {
          // Admin page
}


public boolean userCanGoNext() throws IOException{
    BufferedReader br=new BufferedReader(new FileReader("LoginInformation.txt"));
    String line;
    while( (line=br.readLine()) != null ){
        String[] celledinfo= line.split("     ");
        String userN=celledinfo[4];
        String passN=celledinfo[5];

        if(userN.equals(username.trim()) && passN.equals(String.valueOf(Password))){
            return true;
        }
    }
    return false;
}

public void goUserMainPage(){
          // User Page

}
}

my txt file:

Admin:     1     2
User:     1     3

i dont write generated codes by netbeans. (my first index in jcombobox is admin and second is user)

Thanks for help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:57:02+00:00Added an answer on June 18, 2026 at 3:57 pm

    In adminCanGoNext you are checking the user/password against every line of your password file. You don’t take care of the fact that the user selected “User” or “Admin”. (and so that you only need to match against lines starting with “Admin:” or against lines starting with “User:”)

    In userCanGoNext : there is a similar mistake, but additionally, you are looking for username and password at index 4 and 5.
    According the file template you have posted: the array resulting of the split will never have more than 3 elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating a login page. I want to create ASP.NET TextBox controls that have
I have a Login page that captures User input like this. MD5calc ss =
I'm using ASP.NET MVC 2 and have a login page that is secured via
So, I have set up a login page that verifies the user's credentials, and
I have code that redirects visitor to login -page via authentication provider selector -page
I have written a django page that requires only super users to login. So
I have a TextView that displays an error message in the login page of
I have an Employee class object that I am calling from my Login.aspx page's
I have made a web application that uses master page for Login & Logout
I am using a PHP login script that challenges user for username & password.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.