• Post Reply Bookmark Topic Watch Topic
  • New Topic

After login display other data in mysql db  RSS feed

 
Lee Martin Flores
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there a way to make a  login form, which fetch data from database, and if username and password match, then it redirect to one form, in which there's multiple field and you want that that form filled automatically by retrieving mysql data?
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

How are you logging on? Are you storing the passwords (that would be wrong) or are you using a hashing algorithm? Many databases have a password() program which will do the hashing for you.
I suggest you start with this tutorial. If you are using this program for real‑life use, you shou‍ld probably buy a login package rather than trying to write your own.
 
Campbell Ritchie
Marshal
Posts: 56518
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have added code tags to your post; always use the tags. Doesn't it look better Unfortunately, it shows that your indentation is inconsistent.
You have a serious error on line 17: an empty catch. That means you would never know if an exception occurs.
 
Lee Martin Flores
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Welcome to the Ranch

How are you logging on? Are you storing the passwords (that would be wrong) or are you using a hashing algorithm? Many databases have a password() program which will do the hashing for you.
I suggest you start with this tutorial. If you are using this program for real‑life use, you shou‍ld probably buy a login package rather than trying to write your own.


Im not really using it for real life, im usually doing this because its my finals in Advance Programming.
Is there anyway to edit my post so i can update my code?
Here's My updated code:


Then in the 2nd Form:
This is what i came up with. But nothing's showing up in Welcome user textfield. Is there something that i did wrong?
 
Ganesh Patekar
Bartender
Posts: 726
23
Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the second form you are creating new object of class Login, here on line number 2 in above example in method Display() which has It's own separate instance variable String currentUser initialized with default value null.

I think that is why you may not get the current user name set to Welcomeuser textfield. You can create a parameterized consructor of class Studentmenu and pass that currentUser name. Declare a separate String currentUser variable in class Studentmenu and assign It the value of variable passed as argument to parameterized constructor of Studentmenu.

  • It is recommended that, method name better start with first word in lowercase and following words in CamelCase.
  • Yout variable names are also not according to naming convention like Studentid which better be studentId.
  • You can refer this Oracle Naming Conventions
  • It is good to close Connection, PreparedStatement and ResultSet immediately after It's use. In method loginPerformed you didn't close them.
  • You declared local variable Studentid which is never used in method Display.
  • I don't know how you designed student table in database. In login form you are using student name and password to verify account but did you consider what If two students have same name?
  •  
    Ganesh Patekar
    Bartender
    Posts: 726
    23
    Eclipse IDE Hibernate jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Lee Martin Flores wrote:Is there anyway to edit my post so i can update my code?
    You can again post new updated code no problem. If It has error please also post complete error beneath the code( Post only code in code tags).
     
    Knute Snortum
    Sheriff
    Posts: 4270
    127
    Chrome Eclipse IDE Java Postgres Database VI Editor
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Ganesh Patekar wrote:
    Lee Martin Flores wrote:Is there anyway to edit my post so i can update my code?
    You can again post new updated code no problem. If It has error please also post complete error beneath the code( Post only code in code tags).

    And it is actually better to not edit your old post in these circumstances.  It might make the proceeding comments hard to understand.  And it's often nice to see the progression of updating code -- something every programmer does.
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!