0

我有登录和注册码。但它怎么能有效呢?我可以在框中输入,但我当然没有效果,因为我不知道如何让人们真正登录。:P

注册码:

    <!doctype html>
<html>
    <head>
        <style type="text/css">

            body {font-family:Arial, Sans-Serif;}

            #container {width:300px; margin:0 auto;}

            /* Nicely lines up the labels. */
            form label {display:inline-block; width:140px;}

            /* You could add a class to all the input boxes instead, if you like. That would be safer, and more backwards-compatible */
            form input[type="text"],
            form input[type="password"],
            form input[type="email"] {width:160px;}

            form .line {clear:both;}
            form .line.submit {text-align:right;}

        </style>
    </head>
    <body>
        <div id="container">
            <form>
                <h1>Sign-up Here!</h1>
                <div class="line"><label for="username">Username: </label><input type="text" id="username" /></div>
                <div class="line"><label for="pwd">Password: </label><input type="password" id="pwd" /></div>
                         <div class="line"><label for="pwd">Confirm Password: </label><input type="password" id="pwd" /></div>


                <div class="line submit"><input type="submit" value="Submit" /></div>


            </form>
        </div>
        <center><p>Do NOT use your ZeldaUniverse log-in! For your own security!</p></center>
    </body>
</html>

Log in code:

    <html>
<head>
<title>Please type your Username and Password... </title>
<script language="JavaScript" type="text/JavaScript" src="login.js"></script>
</head>
<body bgcolor="#eeeeee">
<form>
<br>
<center>
Username: <input type="text" name="username" style="background:#bfbfbf;color:#212121;border-color:#212121;" onFocus="this.style.background = '#ffffff';" onBlur="this.style.background = '#bfbfbf';">
<br>
Password: <input type="password" name="password" style="background:#bfbfbf;color:#212121;border-color:#212121;" onFocus="this.style.background = '#ffffff';" onBlur="this.style.background = '#bfbfbf';">
<br>
<input type="button" value="Login" onClick="Login(this.form);" style="background:#bfbfbf;color:#000000;border-color:#212121;" onMouseOver="this.style.color = '#404040';" onMouseOut="this.style.color = '#000000';" onFocusr="this.style.color = '#404040';" onBlur="this.style.color = '#000000';">
</center>
</form>
<center><font style=""
</body>
</html>




<!-- Begin

    function Login(form) {
    username = new Array("u1","u2","u3","u4","u5","u6","u7","u8","u9","u10");
    password = new Array("p1","p2","p3","p4","p5","p6","p7","p8","p9","p10");
    page = "secretpage" + ".html";
    if (form.username.value == username[0] && form.password.value == password[0] || form.username.value == username[1] && form.password.value == password[1] || form.username.value == username[2] && form.password.value == password[2] || form.username.value == username[3] && form.password.value == password[3] || form.username.value == username[4] && form.password.value == password[4] || form.username.value == username[5] && form.password.value == password[5] || form.username.value == username[6] && form.password.value == password[6] || form.username.value == username[7] && form.password.value == password[7] || form.username.value == username[8] && form.password.value == password[8] || form.username.value == username[9] && form.password.value == password[9]) {
    self.location.href = page;
    }
    else {
    alert("Either the username or password you entered is incorrect.\nPlease try again.");
    form.username.focus();
    }
    return true;
    }

感谢阅读和帮助!;)

聂莉,

4

1 回答 1

0

html仅用于图形显示,您需要学习一些编程语言才能真正进行登录。我个人使用java。您肯定需要包含一个操作(稍后调用的 servlet 的 url)和一个 http 方法,因为这是网络上使用的协议。您可以这样做:

在 html 文件中:

<form action="singin" method="post">
    <input type="text" id="username"/>
    <input type="password" id="password"/>
    <button type="submit">Log in</button>
</form>

通过创建一个 nex 类并扩展一个 httpservlet 在您的 java 代码中创建一个 servlet,然后转到您的 xml 文件并将请求从表单映射到您刚刚创建的 servlet。

于 2014-04-09T12:59:08.467 回答