Good.
I'm trying to make a program that looks at whether the password of a form is in a file.txt.
The file is line by line in this way:
000
010
001
...
Keep this up with a lot of passwords but it's for you to come to the idea.
My code of AJAX where $ ("# pass" would be where is the password):
$("#pass").on("change",function(){
var data = $("#pass");
var request = $.ajax({
url:'egiaztatuPosta.php',
data: data,
dataType:'html'
});
request.done(function(data){
echo("No está dentro");
});
request.fail(function(data){
echo("Está dentro");
});
});
My code PHP :
$pasahitzak = fopen('../DATUAK/toppasswords1.txt','r');
$aurk=false;
$zenb=0;
while($linea = fgets($pasahitzak)){
$aux[] = $linea;
echo "<script>console.log( 'Pasahitza: " . "$_REQUEST[pasahitza]" . "' );</script>\n";
echo "<script>console.log( 'Lerroa: " . $linea . "' );</script>\n";
if("$_REQUEST[pasahitza]"==$linea){
$aurk=true;
}
echo "<script>console.log( 'Finala: " . $ald . "' );</script>";
}
fclose($pasahitzak);
What I want to know is if there is any way for the AJAX to perform the fail function when $ aurk equals true ($ aurk = true). I think that with those two bits of code is enough to expose my doubt. If you need some more code because it's not enough, put it in the comments.
I have not found anything useful and that's why I ask. Greetings.