如何制作简单的密码页面 [英] How do I make a simple password page

查看:282
本文介绍了如何制作简单的密码页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(当心,英语不好) 我正在尝试创建一个只有一个小块"的页面,您可以在其中输入设置的密码.

(Beware, bad english) I am trying to create a page wich just has a ''small block'' in where you can type a password wich I have set.

如果您输入了正确的密码并按输入站点"按钮,您将发送到下一页.

If you typed in the right password and press the ''Enter site'' button you will get send to the next page.

这不必是一个受到完全保护的网站,只需输入1行表单(如果输入的密码正确),该表单就会将您发送到html代码指定的页面中.

This doesn't have to be a fully protected website just a 1line form that sends you to a in the html code specified page if the typed in password is right.

我是我学校的一年级学生,并且非常喜欢使用html进行学习,但是由于我比其他班级都要好很多,所以我想学习更多,所以我希望有人能为我提供帮助与此.

I am a first year student on my school and really enjoying workin with html but since I am kind off far ahead of the rest of the class I would like to learn more, so I hope that there is someone who can help me with this.

提前谢谢!

这是我在photoshop中制作的一个示例

推荐答案

仅HTML不能做到这一点,您需要在后端使用其他语言来检查密码.或者,您可以使用javascript来在前端验证密码,但是只有在您出于娱乐目的而必须在代码本身中指定密码.否则,要开发具有登录页面的Web应用程序,您需要使用后端语言(例如php或python)和数据库(例如mysql或mariadb)来存储密码.

HTML alone can't do this you need some other language in backend to check password. Or you can use javascript which will verify password in frontend but you have to specify password in the code itself only if you are doing it for fun. Otherwise for developing web app with login page you need a backend language such as php or python and database such as mysql or mariadb to store passwords.

示例代码
您需要创建两个文件,一个用于登录表单(login.html),另一个用于在输入正确密码后重定向(welcome.html).

Sample code
You need to create two files one for your login form (login.html) and another to redirect after right password is entered (welcome.html).

此代码用于login.html

This code is for login.html

    <!DOCTYPE html>
<html>
<head>
    <title>Login page</title>
</head>
<body>
<form>
    <label for="pswd">Enter your password: </label>
    <input type="password" id="pswd">
    <input type="button" value="Submit" onclick="checkPswd();" />
</form>
<!--Function to check password the already set password is admin-->
<script type="text/javascript">
    function checkPswd() {
        var confirmPassword = "admin";
        var password = document.getElementById("pswd").value;
        if (password == confirmPassword) {
             window.location="welcome.html";
        }
        else{
            alert("Passwords do not match.");
        }
    }
</script>
</body>
</html>

此代码用于welcome.html

This code is for welcome.html

<!DOCTYPE html>
<html>
<head>
    <title>Welcome page</title>
</head>
<body>
<h1>Welcome!! you entered a right password</h1>
</body>
</html>

这篇关于如何制作简单的密码页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆