假設我在login.html頁面中有一個「登錄」按鈕。該JavaScript可以這個樣子通過單擊「登錄按鈕」驗證登錄頁面中的JavaScript使用javascript
var attempt = 3; // Variable to count number of attempts.
// Below function Executes on click of login button.
function validate(){
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
if (username == "Formget" && password == "formget#123"){
alert ("Login successfully");
window.location = "success.html"; // Redirecting to other page.
return false;
}
else{
attempt --;// Decrementing by one.
alert("You have left "+attempt+" attempt;");
// Disabling fields after 3 attempts.
if(attempt == 0){
document.getElementById("username").disabled = true;
document.getElementById("password").disabled = true;
document.getElementById("submit").disabled = true;
return false;
}
}
}
在我做if (username == "Formget" && password == "formget#123")
的代碼,我有2個screnarios
1)我需要從2個獨立的外部MYSQL數據庫獲得用戶列表,並串聯成一個列表(可以編寫python腳本來生成該列表,沒有問題)
2)有資格登錄的用戶需要根據LDAP鏈接進行驗證以驗證其密碼。只有這樣他們才能進入主頁。
我正在使用燒瓶應用程序(使用apache和mod_wsgi來運行它)。儘管燒瓶有其自己的處理方式,但我對處理這種問題的一種便捷方式感到困惑。請幫忙,我是初學者。