java-user-authentication-system

πŸ” User Authentication System β€” PN Solutions

A console-based User Authentication & Profile Management System built with Core Java and MySQL via JDBC. This project enables secure user registration, login, profile management, and account deletion β€” all through an interactive command-line interface.


πŸš€ Features

βœ” User Registration β€” New users can sign up with name, email, username, and password with data stored directly to MySQL.
βœ” Secure Login β€” Authenticates user credentials against the database using parameterized queries.
βœ” View Profile β€” Displays the logged-in user’s complete profile details post-login.
βœ” Update Profile β€” Allows users to modify their name, email, username, and password.
βœ” Delete Account β€” Permanently removes user account with a confirmation prompt before deletion.
βœ” User Dashboard β€” Clean post-login menu to navigate all profile actions seamlessly.
βœ” Logout β€” Safely exits the current user session back to the home screen.


πŸ› οΈ Technologies Used


πŸ“‚ Project Structure


πŸ—„οΈ Database Setup

Run the following SQL script in your MySQL client (also available in query.sql):

-- Create Database
CREATE DATABASE user_db;

-- Use Database
USE user_db;

-- Create Users Table
CREATE TABLE users (
    id         INT PRIMARY KEY AUTO_INCREMENT,
    name       VARCHAR(50)   NOT NULL,
    email      VARCHAR(100)  UNIQUE NOT NULL,
    username   VARCHAR(50)   UNIQUE NOT NULL,
    password   VARCHAR(100)  NOT NULL,
    created_at TIMESTAMP     DEFAULT CURRENT_TIMESTAMP
);

βš™οΈ Configuration

Open DBconnection.java and set your MySQL credentials:

private String url      = "jdbc:mysql://localhost:3306/user_db";
private String username = "your_mysql_username";
private String password = "your_mysql_password";

⚠️ Security Note: Never push real credentials to version control. Use environment variables or a config.properties file and add it to .gitignore.



πŸ–₯️ Application Flow

HomePage (Main Menu)
β”‚
β”œβ”€β”€ [1] Register ──────────► RegisterUser
β”‚                                 └── Inserts into MySQL β†’ Optional Login redirect
β”‚
β”œβ”€β”€ [2] Login ─────────────► LoginPage
β”‚                                 └── Authenticates β†’ Dashboard
β”‚                                           β”œβ”€β”€ [1] View Profile
β”‚                                           β”œβ”€β”€ [2] Update Profile ──► updateProfile
β”‚                                           β”œβ”€β”€ [3] Delete Account ──► DeleteProfile
β”‚                                           └── [4] Logout
β”‚
└── [3] Exit

πŸ“– Learning Outcomes

This project demonstrates proficiency in:


πŸ‘€ Author

Pravin PR
🏒 PN Solutions
πŸ“ Tamil Nadu, India


πŸ’‘ This project is built for educational purposes to demonstrate Java-MySQL integration using JDBC. For production use, implement password hashing (BCrypt), input validation, and secure credential management.