Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
moving JS to script file
  • Loading branch information
Zzza38 authored Feb 12, 2024
1 parent a326046 commit 07351cb
Showing 1 changed file with 1 addition and 35 deletions.
36 changes: 1 addition & 35 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,7 @@ <h2>Login</h2>
<input type="password" id="password" name="password" required><br><br>
<button type="submit">Login</button>
</form>
<script src="index/main.js"></script>

<script>
// Define an array to store usernames and passwords (for demonstration purposes only)
const users = [
{ username: 'zion', password: '7979' },
{ username: 'william', password: '11221122' },
{ username: 'james', password: 'james2012' },
{ username: 'sammy', password: 'panther1234' },
{ username: 'lerone', password: 'b0ngu$verb' },
{ username: 'gio', password: '1234' },
{ username: 'rebecca', password: '3981' },
{ username: 'nathaniel', password: 'big' },
{ username: 'rafael', password: 'rafaeln1' },
];

document.getElementById("loginForm").addEventListener("submit", function(event) {
event.preventDefault(); // Prevent form submission

// Get input values
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;

// Check if the entered username and password match any user in the array
const user = users.find(u => u.username === username && u.password === password);
if (user) {
// Set a cookie indicating that the user is logged in
document.cookie = "loggedIn=true; path=/";
document.cookie = "user=username; path=/";
document.cookie = "pass=password; path=/";
// Redirect to the chooserblx.html page
window.location.href = "gameselect.html";
} else {
alert("Invalid username or password");
}
});
</script>
</body>
</html>

0 comments on commit 07351cb

Please sign in to comment.