0

I'm making a site with a login thing. The usernames/passwords will be stored in the website files as .txt. (I know it's not safe. This isn't meant to be safe. It's a test to see if people can crack one of the passwords). Here is the current code:

var attempt = 3;

function validate(){
 var username = document.getElementById("username").value;
 var password = document.getElementById("password").value;

 if ( username == "username" || username == "Username" && password == "B6YC98"){
  window.location = "success.html"; 
  return false;
 }
 else{
  attempt --;
  alert("You have "+attempt+" attempt(s) left;");
  
  if( attempt == 0){
   document.getElementById("username").disabled = true;
   document.getElementById("password").disabled = true;
   document.getElementById("submit").disabled = true;
   return false;
  }
 }
}

How would I make it so it checks if the username you entered, is equal to a username from usernames.txt? And the same for the passwords.

1 Answers1

0

I might be confused, but all someone would have to do is watch the network traffic after doing your first login attempt to see that usernames.txt or password.txt are files being called. Then they could just access those directly?

But, assuming you don't mind that: Javascript - read local text file

Community
  • 1
  • 1
radiantstatic
  • 342
  • 4
  • 20
  • Thanks. And no, I don't mind if they do that. I'm making this deliberately to test people. –  Jul 08 '16 at 18:45