I'm a having a serious problem creating variable.

I am creating an application that gets its datas from a database, and before you can access the application you must login first.

My problem now is my Login class can do all the validations but I don't know how to set the information of the user that just logged in to class home so that the home class will be showing the user's information.

Please help me with a Java code that can do that or tell me what to do....

hello
if I don't mistakenly understood your case

1.you must put name and password of the user in database ,or in side the code
2.after the user click button to login,user name and password just typed is compared to the strored name and password
3.if both equals then the user brought to be able to do whatever else in application
find example in sun java tutorial example index

hello
if I don't mistakenly understood your case

1.you must put name and password of the user in database ,or in side the code
2.after the user click button to login,user name and password just typed is compared to the strored name and password
3.if both equals then the user brought to be able to do whatever else in application
find example in sun java tutorial example index

Yes but I have Already done that, the login page can validate and if the username and password is correct it will open the home class, my problem now is i want the logon user details to be stored in a variable in the home class so that i can use these stored info in the variable later. just like in web design we have session variable when the user logon

in home class you declare the empty variable for the logon user.
if the name and password is equal to certain name and password
then read from database to fill empty variable for that logon user

denny

in home class you declare the empty variable for the logon user.
if the name and password is equal to certain name and password
then read from database to fill empty variable for that logon user

denny

Danny that is exactly what am looking for I only just need the code on how to fill the empty variable in the home class from the login class, don't worry about how getting d username and password to be correct in the datbabse I have already done that, I only need how to set the variable from login class to the home class, pls help me with code...

maxinville, this question is a bit weird, in my eyes.
you either have copied that code from somewhere, or you are capable of getting information from a DB.

say you have a class

User
=> that has two Strings, userName, password.
=> that has one constructor which takes both Strings mentioned above as parameters

the next two pieces of code are based on the idea that: either you store all separate variables in your db, or you store the object itself in the DB

User myUser;
if ( loginCorrect(userName, password) ){
  myUser = new User(userName, password);
}
User myUser;
if ( loginCorrect(userName, password) ){
  myUser = readUserFromDB(userName);
}

the above is just the logic, not the entire code off course.

This article has been dead for over six months. Start a new discussion instead.