0

私は現在、ユーザーがボタンをクリックして条件に同意するだけで通過できるようにする作業コードを持っています。パスワードが正しい場合にのみ誰かを許可するパスワードフィールドと同意ボタンを統合したいと思います。

シンプルなボタンを使用した現在の作業コードは次のとおりです。

Agree to Connect:
<br>
<br>
<form method="post" id="login" action="http://10.0.0.1:5280/">
<input type="hidden" name="accept_terms" value="yes">
<input type="hidden" name="redirect" value="http://www.anderson1216.com/wifi-success.html">
<input type="hidden" name="mode_login">
<input type="submit" value="Accept Terms of Use and Connect">
</form>
<br>
//agreement text here
<br>
<br>
We thank you for your understanding and cooperation.
<br>
<br>
<form method="post" id="login" action="http://10.0.0.1:5280/">
<input type="hidden" name="accept_terms" value="yes">
<input type="hidden" name="redirect" value="http://www.anderson1216.com/wifi-success.html">
<input type="hidden" name="mode_login">
<input type="submit" value="Accept Terms of Use and Connect">
</form>

これは、私が見つけた簡単なパスワード フォームです。

<head>
<script type="text/javascript">
function isValid(){
var password = document.getElementById('password').value;
if (password == "password123")
{alert('Correct!')
else
{alert('Wrong Password')}
}
</script>
</head>

<form name="PasswordField" action="">
Password:
<input type="password" id="password" name="password">
<input type="button" value="Log in" onclick="isValid();">
</form>

コードが機能するためには、コードの最初のブロックの最初のステートメントをどこかに含めて、その人が受け入れたことをルーターに伝え、ボタンをクリックした後に別の Web サイトにリダイレクトする必要があります。正しいパスワードには警告は必要ありません。間違ったパスワードだけです。助言がありますか?

4

4 に答える 4

0

おそらくランディングページとして、これをホームルーターに配置したいようですか?もう少し詳しく教えていただければ、より多くの助けを提供できるかもしれません。

秘密のパスワードを知らない人がサイトにアクセスできないようにする場合、これは適切な方法ではありません。クライアント側ではなく、サーバー側でユーザーを認証する必要があります。JavaScript の知識が限られている人なら誰でも、開発者コンソールを使用してクライアント側で認証を偽装できるからです。

ただし、任意の既知のパスワードを入力して、人間が契約条件に同意していることを確認したいだけの場合は、この方法で問題ありません。

于 2016-02-12T04:53:02.187 に答える