Login Page

I want this developer.html to go to index.html when I press login if the username and password are correct. here is the code
<!DOCTYPE html>
<html>
<head>
<title>Developer Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="form-box">
<h1>Login Here</h1>
<div class="input-box">
<input type="email" placeholder="Email or Username" id="emailInput">
</div>
<div class="input-box">
<input type="password" placeholder="password" id="passwordInput">
</div>
<button class="login-btn" onclick="loginButton(this)" value="index.html">LOGIN</button>
</div>
<script>
function loginButton(link){
let email = "PD";
let password = "PDP";

if(document.getElementById("passwordInput") === password){
if(document.getElementById("emailInput") === email){
console.log(link.value);
location.href = link.value
};
};
};
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Developer Login</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="form-box">
<h1>Login Here</h1>
<div class="input-box">
<input type="email" placeholder="Email or Username" id="emailInput">
</div>
<div class="input-box">
<input type="password" placeholder="password" id="passwordInput">
</div>
<button class="login-btn" onclick="loginButton(this)" value="index.html">LOGIN</button>
</div>
<script>
function loginButton(link){
let email = "PD";
let password = "PDP";

if(document.getElementById("passwordInput") === password){
if(document.getElementById("emailInput") === email){
console.log(link.value);
location.href = link.value
};
};
};
</script>
</body>
</html>
5 Replies
Jochem
Jochem5mo ago
you're comparing document.getElementById()'s output (which is an HTMLElement) to a string, so that will never work. You have to use document.getElementById().value === password I do hope you are aware this is horrificly insecure, right? like, it's fine as an exercise, but never ever ever do this for anything that even matters a tiny bit
Greener
Greener5mo ago
I do understand. This is for a website for developers of a roblox group. It is for them to look at for announcements and other stuff. I will think of better credentials for it soon but that is what I have got for testing.
Jochem
Jochem5mo ago
A significant percentage of even the most unskilled people (not even talking and hackers) that want to get past that will take all of ten minutes to do so, and mostly because it'll take them nine minutes to recover from laughing so hard at the fact the password is in the Javascript. It being three characters is moot at that point You're better off just having a page that isn't linked anywhere on your site and sending that link to the people that should have access over dms, at least that way an attacker won't have the link served on a platter
Greener
Greener5mo ago
Would you be able to maybe help me with making registration and encryption? The username and passwords were also just for testing the website before it would go even somewhat public. I will hopefully be able to get encryption and a database for different accounts later. Also I am going to mark this post as solved now. Thank you!
Jochem
Jochem5mo ago
Sorry, that's not something I can commit to. You should ask in potentially a new post, but I'd recommend you do some research and maybe try to find some tutorials online first, the more focused a question is the better the answers will be.