Good, I have a text file with several possible passwords saved like this:
0
00
000
1
11
111
123
There are many more but it is to teach where the shots go. I do not know how to read it line by line and compare it with the password that the user is entering. The code I have is this (to read the file, taken from another Stack Overflow thread):
$(document).ready(function() {
$("#pass").on("change", function() {
$('#posta').val("Jijiji");
var path = "../DATUAK/toppasswords.txt";
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id='page-wrap'>
<span><a href='../HTML5/layout.html'>Atzera</a></span> <br><br>
<h2>Quiz: crazy questions</h2>
<div>
<form id="galderenF" name="galderenF" method="post" action="signUp.php" onsubmit="return balidatu()">
<label for="posta"><strong>Posta (*):</strong></label>
<input type="email" name="posta" id="posta" placeholder="Zure posta" pattern="[a-zA-Z]{2,}[0-9]{3}@ikasle\.ehu\.(eus|es)" required/><br>
<label for="deitura"><strong>Deitura (*):</strong></label>
<input type="text" name="deitura" minlength="10" id="galdera" placeholder="Zure deitura" required/><br>
<label for="nick"><strong>Nick (*):</strong></label>
<input type="text" name="nick" id="erantzunZuzena" placeholder="Zure nick-a" required/><br>
<label for="pasahitza"><strong>Pasahitza (*):</strong></label>
<input type="password" name="pasahitza" minlength="6" id="pass" placeholder="Pasahitza" required/><br>
<label for="pasEr"><strong>Pasahitza Errepikatu (*):</strong></label>
<input type="password" name="pasahitzaRep" minlength="6" id="passC" placeholder="Pasahitza errepikatu" required/><br>
<input class="botoia" type="submit" id="botoia1" value="Erregistratu" />
<input class="botoia" type="reset" id="botoia2" value="Reset" />
<div id="aster"><strong> * | Nahitaezko hutsuneak </strong></div><br><br>
</form>
<div id="ezkutatu1" style='display:block'>Posta egiaztatzen... </div>
<div id="erakutsiEgiaBada1" style='display:none'> Posta onargarria da </div>
<div id="erakutsiGezurraBada2" style='display:none'> Posta existitzen da WSan </div>
<div id="ezkutatu2" style='display:block'> Pasahitza egiaztatzen... </div>
<div id="erakutsiEgiaBada2" style='display:none'> Pasahitza onargarria da </div>
<div id="erakutsiGezurraBada2" style='display:none'> Pasahitza ez da onargarria da </div>
</div>
The problem is that I can not read it line by line, which is what I want to compare it with the password line by line.
I need it in javascript or in jQuery, but in PHP it would be like this:
$pasahitzak = fopen('../DATUAK/toppasswords.txt','r');
while($linea = fgets($pasahitzak) && $ondo==TRUE){
echo $linea.'<br/>';
}
fclose($pasahitzak);
Regards.