Fixy-Fact
Hi,

Are you a member? Please Log In. If not, please click 'Register' on above menu. Quick to register and simply just click here to make an account, this account will become your identity while you enjoy full features of Fixy-Fact forum and make sure you fill in data with correctly.

Make sure you read terms of agreement in our forum to prevent disobedient, click here to go.

Thank you for your concern!

Best,
Fixy-Fact Team

Simple login validation for Java Programming

Go down

Simple login validation for Java Programming

Post by DonFixyboys* on Sun May 20, 2012 1:52 am

Simple login validation for Java Programming

Description: Membuat java program yang memvalidasi saat login sebelum masuk atau melanjutkan command / statement line selanjutnya.

Tutorial :
1. Masukkan code dibawah ini pada class anda
Code:

import java.util.*;

public class LoginValidation {

public static void login() {

Scanner in = new Scanner(System.in);

boolean validation;
String username, password;

do {
         System.out.println("Login First!");
         System.out.println("============");
         System.out.print("\nInput your login ID: ");
         username = in.nextLine();
         System.out.print("Input your password: ");
         password = in.nextLine();         
         
         if(username.equals("testuser") && loginpw.equals("testpassword")) {
            validation = true;
            System.out.println("You are successfully login!");
         }
         
         else {
            validation = false;
            System.out.println("Your ID or Password didn't match!");
         }
         } while(validation == false);

}

public static void main(String[]args) {

login();

}

}

Note:

1. Kalian bisa ganti dibagian ini :

Code:
if(username.equals("testuser") && loginpw.equals("testpassword"))

testuser adalah username yang digunakan saat login dan testpassword merupakan password yang digunakan saat login.

2. Bisa ganti dibagian string statement atau print dll.

Selamat mencoba Smiley Beer

Credit: 100% by Myself
avatar
DonFixyboys*
The Godfather
The Godfather

Posts : 642
Credits : 1395
Reputation : 26
City : Jakarta
Browser : Mozilla Firefox

View user profile

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum