0
Я ищу Простую проверку с помощью текстового файла.проверка с текстовым файлом с использованием JavaScript
Например:
verification.txt
Text: ABC5864
на основе пользовательского ввода, если это правильно, то это позволит войти в противном случае выводит сообщение об ошибке:
<input name="myverification" id="myverification" type="verification" class="form-control" placeholder="verification">
Здесь мой код:
$(document).ready(function() {
"use strict";
$("#submit").click(function() {
var username = $("#myusername").val(), password = $("#mypassword").val();
if ((username === "") || (password === "")) {
$("#message").html("<div class=\"alert alert-danger alert-dismissable\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">×</button>Please enter a username and a password</div>");
} else {
$.ajax({
type: "POST",
url: "checklogin.php",
data: "myusername=" + username + "&mypassword=" + password,
dataType: 'JSON',
success: function (html) {
//console.log(html.response + ' ' + html.username);
if (html.response === 'true') {
//location.assign("../index.php");
location.reload();
return html.username;
} else {
$("#message").html(html.response);
}
},
error: function (textStatus, errorThrown) {
console.log(textStatus);
console.log(errorThrown);
},
beforeSend: function() {
$("#message").html("<p class='text-center'><img src='images/ajax-loader.gif'></p>");
}
});
}
return false;
});
});
<form class="form-signin" name="form1" method="post" action="checklogin.php">
<h2 class="form-signin-heading">Please sign in</h2>
<input name="myusername" id="myusername" type="text" class="form-control" placeholder="Username" autofocus>
<input name="myverification" id="myverification" type="verification" class="form-control" placeholder="verification">
<input name="mypassword" id="mypassword" type="password" class="form-control" placeholder="Password">
<button name="Submit" id="submit" class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
<div id="message"></div>
</form>
Заранее спасибо
, как этот код может прочитать текстовый файл и получить значение? – Jomla