Skip to content
Open
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Project Website Template — Auth & Database Integrated

# project-website-template
Demo: https://yenchiah.github.io/project-website-template/

Expand Down
16 changes: 16 additions & 0 deletions db-config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// WARNING: Demo only. Do NOT store real credentials in client-side code.
const db = {
host: "localhost",
username: "admin",
password: "password123",
};

/**
* Connect to the demo DB.
* @returns {boolean} true if the (mock) connection succeeded
*/
function connectDB() {
console.log("Connected to DB at " + db.host);
return true;
}

23 changes: 23 additions & 0 deletions login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Login Page</title>
</head>
<body>
<h2>User Login</h2>
<form id="loginForm">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required><br><br>

<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br><br>

<button type="submit">Login</button>
</form>

<script src="login.js"></script>
</body>
</html>

12 changes: 12 additions & 0 deletions login.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
document.getElementById("loginForm").addEventListener("submit", function(event) {
event.preventDefault(); // prevent page reload

const username = document.getElementById("username").value.trim();
const password = document.getElementById("password").value.trim();

if (username === "" || password === "") {
alert("Please fill in both fields.");
} else {
alert("Login successful (demo only).");
}
});