Hello everyone! I am currently working on a login code,i've put it in another program and the login is operational.But the thing is when i type in a wrong password,i get a message that tells me invalid password but logs in instead of making me try again, I've tried to put a do while loop with it but ending up with errors. Can anyone help me? here is the code MyLogin in the username and password constructor that i call i n this one!
private boolean login() {
boolean userValid = false; MyLogin Login = new MyLogin (new Frame("")); //Referencing MyLogin requestFocus(); if (Login.id) { username = Login.username.getText(); password = Login.password.getText(); userValid = validateUser(username , password); // System.out.println //("The password for " + username // + " is " + (userValid?"valid":"invalid")); JOptionPane.showMessageDialog(new JFrame(), "The password is invalid for " + username ); }
If you are getting errors, it helps if you tell us exactly what kind of errors they are. Compile errors? Run time errors? Cut-n-pastes of the exact error message you get goes a LONG way in helping people figure out the problem.
Never ascribe to malice that which can be adequately explained by stupidity.
Olliver Lim Kam Sian
Greenhorn
Joined: Sep 26, 2007
Posts: 12
posted
0
im not getting errors anymore but i can't get the code to reject a wrong password or username!here is wat i've done!
private boolean login() { do{ boolean userValid = true; MyLogin Login = new MyLogin (new Frame("")); //Referencing MyLogin requestFocus(); if (Login.id) { username = Login.username.getText(); password = Login.password.getText(); userValid = validateUser(username , password); System.out.println ("The password for " + username + " is " + (userValid?"valid":"invalid")); }
There's a lot of unknowns there for somebody who doesn't have a copy of the rest of your code. So can you tell us what that code does? And tell us what you want it to do, too. That's another unknown.
Olliver Lim Kam Sian
Greenhorn
Joined: Sep 26, 2007
Posts: 12
posted
0
This is the seperate MyLogin.java file,I use the login.java in a client code that is connected to a server to call for MyLogin.java. sincerely I don't know much about the code, butI tried to get it to work properly(i.e enable login when username&password is ok and ask to retype if username or password is wrong) But failed thats why i am turning to you guys!
Thanks for considering my problem
import java.awt.*; import java.awt.event.*;
public class MyLogin extends Dialog implements ActionListener { boolean id = false; Button ok,can; TextField username; TextField password;