Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Please help me in my coding (create a login page that can save password )

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Location
    Singapore
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Please help me in my coding (create a login page that can save password )

    Below is my java coding that i have done,but i have no idea how to save the password after key in the user id and the password.and i also need the system able to unsave the password if the user choose to unsave it .
    Hope you guys will able to help me solve this problem.


    import java.util.Scanner;
    public class Home {
    private static Scanner sc;
    public Scanner readPass;
    static String savedName="";
    static String savedPass="";
    public static void main (String []args)
    {
    String saveQuestion="";
    boolean saveError=true;
    boolean correctCombi=true;
    sc = new Scanner (System.in);
    String password=savedPass,name=savedName;

    int x=0;
    int y=0;

    String[] userName={"a","b","c","d","e","f","g"};
    String[] secret={"1","2","3","4","5","6","7"};
    while(true)
    {
    do
    {


    System.out.print("Enter name : ");
    name = sc.next();
    for (int j=0;j<7;j++)
    {
    if (userName[j].equals(name))
    {
    x=j;
    break;
    }
    else x=123;
    }
    System.out.print("Enter password: ");
    password= sc.next();
    for (int j=0;j<7;j++)
    {
    if (secret[j].equals(password))
    {
    y=j;
    break;
    }
    else y=124;
    }
    System.out.println(x);
    System.out.println(y);
    if(x==y)
    {
    correctCombi= true;
    System.out.println("Correct");
    }
    else
    {
    System.out.println("ID and Password does not match.");
    System.out.println("Please try again");
    correctCombi= false;
    }

    }while(correctCombi!=true);

    do
    {
    System.out.println("Do you want to save this password");
    saveQuestion = sc.next();
    if (saveQuestion.equals("yes"))
    {
    savedName= name;
    savedPass= password;


    saveError=false;
    break;
    }
    else if (saveQuestion.equals("no"))
    {
    savedName="";
    savedPass= "";
    saveError=false;
    break;
    }
    else
    {
    saveError=true;
    System.out.println("Please try again");
    }

    }
    }
    }
    private static Readable Readable(String savedName2) {
    // TODO Auto-generated method stub
    return null;
    }
    }
    Last edited by sugarwendy; August 3rd, 2014 at 11:44 AM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Please help me in my coding (create a login page that can save password )

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly using code or highlight tags per the above link.

Similar Threads

  1. [SOLVED] Jsoup cant Login on Page
    By pedromoto4 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 6th, 2013, 06:13 AM
  2. How to do MD5 encryption in JSP for password login and registration?
    By sadaharu in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: June 21st, 2012, 11:58 AM
  3. i need coding for simple login
    By nag in forum JavaServer Pages: JSP & JSTL
    Replies: 2
    Last Post: September 29th, 2011, 02:30 PM
  4. Login Page error
    By abhiM in forum What's Wrong With My Code?
    Replies: 7
    Last Post: August 23rd, 2011, 07:30 AM
  5. login page with image
    By balu424525 in forum AWT / Java Swing
    Replies: 1
    Last Post: June 26th, 2011, 11:24 AM