Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Rajesh GamiRank #30 · 41.5K reputationPosted Oct 31, 2025, 10:30 AM EDT
1) Database — SQL Script
Create a
Userstable to store user info:2) ASP.NET Core Web API (Backend)
Assumptions:
.NET 8 or later
Using EF Core for DB access
Using
PasswordHasherto hash passwordsUsing JWT Bearer tokens
a)
appsettings.json(add your connection string and JWT settings)b) Models
Models/User.csDTOs/RegisterDto.csDTOs/LoginDto.csc)
AppDbContextData/AppDbContext.csd) JWT Service
Services/JwtService.cse) Auth Controller
Controllers/AuthController.csf)
Program.cs(minimal hosting)g) EF Core migration (run in terminal)
3) Angular (Frontend)
Assumptions:
Angular 15+ (HttpClient available)
Create Angular app and add
@auth0/angular-jwtoptionally for token helper (but not required)We'll create
AuthService,AuthInterceptor,RegisterComponent,LoginComponent,DashboardComponenta)
auth.service.tssrc/app/services/auth.service.tsb)
auth.interceptor.ts(attach token)src/app/interceptors/auth.interceptor.tsRegister the interceptor in
app.module.tsproviders:c)
register.component.ts(simple)d)
login.component.tse)
dashboard.component.tsf) Routing (basic)
app-routing.module.tsSandhiya PriyaRank #26 · 43.2K reputationPosted Jan 6, 2026, 11:03 PM EST
you want a Register/Login system with a dashboard connected to a database. Let’s break this down step by step so you can implement it cleanly.
Tech Stack Options
You can build this with many stacks. Here are two common ones:
PHP + MySQL (classic, simple to host)
Node.js + Express + MongoDB/MySQL (modern, flexible)
I’ll show you a basic PHP + MySQL example since it’s straightforward.
Project Structure
Database Setup (MySQL)
CREATE DATABASE user_system; USE user_system; CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL UNIQUE, password VARCHAR(255) NOT NULL );db.php (Database Connection)
connect_error) { die("Connection failed: " . $conn->connect_error); } ?>register.php
prepare($sql); $stmt->bind_param("ss", $username, $password); if ($stmt->execute()) { echo "Registration successful! Login"; } else { echo "Error: " . $stmt->error; } } ?> Username: Password: Registerlogin.php
prepare($sql); $stmt->bind_param("s", $username); $stmt->execute(); $result = $stmt->get_result(); if ($row = $result->fetch_assoc()) { if (password_verify($password, $row['password'])) { $_SESSION['username'] = $username; header("Location: dashboard.php"); exit(); } else { echo "Invalid password."; } } else { echo "No user found."; } } ?> Username: Password: Logindashboard.php
logout.php
With this setup:
Users can register ? stored in DB with hashed password.
Users can login ? verified against DB.
Successful login ? redirected to dashboard.
Session ensures only logged-in users see dashboard.
Logout clears session.