0
我創建了一個非常非常基本的登錄系統。代碼工作正常,但如果您檢查元素,您可以看到所有讀取用戶名和密碼的if。我的代碼是:如何保護登錄系統
`
<html>
<body>
<form name="login">
Username: <input type="text" style="height:20px;width:150px;" name="un" id="un"
<input type="button" onclick="login();" value="login" />/><br>
Password: <input type="password" style="height:20px;width:150px;" name="ps" id="ps" /><br>
</form>
</body>
</html>
and my checking function is:
<script language="javascript">
function login()
{
if(login.un.value == "user1" && login.ps.value == "user1") {
alert("user1"):
} else {
if(login.un.value == "user2" && login.ps.value == "user2") {
alert("user2");
} else {
alert("Unknown details");
}
}
</script>
您不應該使用JavaScript或任何其他客戶端語言創建登錄系統。考慮使用PHP或Rails來代替。 –
基本上你試圖在javascript上創建完整的登錄信息,這是從檢查元素或視圖源訪問的開放信息。你需要完全從服務器端處理。檢查這是一個PHP指南:http://phppot.com/php/php-login-script-with-session/ –