Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如果我给相同的字母表加上不同大小写的密码,则表单接受_Java_Html_Mysql_Database - Fatal编程技术网

Java 如果我给相同的字母表加上不同大小写的密码,则表单接受

Java 如果我给相同的字母表加上不同大小写的密码,则表单接受,java,html,mysql,database,Java,Html,Mysql,Database,当我尝试使用正确的用户名和错误的密码登录表单时(密码大小写不同,但字母相同),它正在登录 当我试图用正确的密码和错误的用户名(用户名大小写不同,但字母相同)登录表单时,它正在登录 我需要停止登录,这意味着我如何才能使其在密码中区分大小写。它应该在创建表时在数据库中完成,或者我们可以在程序中完成 Login.html 用户登录 表{ 字体系列:Arial; 字体大小:13px; 对齐:居中; 边界:0px; 背景色:#F2F2; 边缘顶部:55px; 细胞间距:10em; } 函数validat

当我尝试使用正确的用户名和错误的密码登录表单时(密码大小写不同,但字母相同),它正在登录

当我试图用正确的密码和错误的用户名(用户名大小写不同,但字母相同)登录表单时,它正在登录

我需要停止登录,这意味着我如何才能使其在密码中区分大小写。它应该在创建表时在数据库中完成,或者我们可以在程序中完成

Login.html

用户登录
表{
字体系列:Arial;
字体大小:13px;
对齐:居中;
边界:0px;
背景色:#F2F2;
边缘顶部:55px;
细胞间距:10em;
}
函数validateForm(){
var id=document.signup.LoginId;
var password=document.signup.LoginPassword;
如果(id.value==“”){
警告(“错误:应填写用户名。”);
id.focus();
返回false;
}
re=/^\w+$/;
如果(!重新测试(id值)){
window.alert(“错误:用户名只能包含字母、数字和下划线”);
id.focus();
返回false;
}
如果(id长度<6){
警告(“错误:用户名必须至少包含6个字符。”);
id.focus();
返回false;
}
如果(id长度>12){
警告(“错误:用户名不能超过12个字符。”);
id.focus();
返回false;
}
if(password.value!=cpassword.value){
警告(“错误:密码和确认密码应该相同。”);
password.focus();
返回false;
}
如果(password.value!=“”){
如果(密码长度<6){
警告(“错误:密码必须至少包含6个字符。”);
password.focus();
返回false;
}
如果(password.length>12){
警告(“错误:密码不能超过12个字符。”);
password.focus();
返回false;
}
if(password.value==id.value){
警告(“错误:密码必须与用户名不同。”);
password.focus();
返回false;
}
re=/[0-9]/;
如果(!重新测试(密码值)){
警告(“错误:密码必须至少包含一个数字。”);
password.focus();
返回false;
}
re=/[a-z]/;
如果(!重新测试(密码值)){
警告(“错误:密码必须至少包含一个小写字母(a-z)。”;
password.focus();
返回false;
}
re=/[A-Z]/;
如果(!重新测试(密码值)){
警告(“错误:密码必须至少包含一个大写字母(A-Z)。”;
password.focus();
返回false;
}
}否则{
警告(“错误:请检查您是否输入了密码。”);
password.focus();
返回false;
}
if(id.value | | password.value!有效){
window.alert(“用户名和/或密码无效,请重试”);
id.focus();
返回false;
}
}
如果您是新用户,请。如果您已经有帐户,请登录

用户名 密码 如果您忘记了密码,请输入您的密码。
示例:如果我的用户名是sapankumar45,密码是KumRekha23

如果我将这些详细信息输入为sapankumar45和kumRekh23(它正在工作)
或者,如果我将这些详细信息输入为SAPANkumar45和KumRekha23(那么它也在工作)。

我们需要一些代码。如何检查用户名和密码?请提供表单输入验证、数据访问方法等。表单(和html)不检查密码是否有效。它只是检查它是否符合您的要求。您的代码在哪里?您在哪里根据数据库中的已知用户检查用户名和密码?我不知道如何根据数据库验证用户名和密码。所以,我为servlet中的错误创建了错误页面。如果你能帮助我在javascript中对数据库验证用户名和密码,那会很有帮助。这不能只用javascript和mysql来完成。你也必须学习PHP。您将使用PHP对用户和密码进行服务器端身份验证。你可以开始了。
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>User Login</title>
<style>
table {  
font-family: Arial;
font-size: 13px;
align: center;
border: 0px;
background-color: #F2F2F2;
margin-top: 55px;
cell-spacing: 10em;
}
</style>
<script type="text/javascript">
function validateForm() {
var id = document.signup.LoginId;
var password = document.signup.LoginPassword;

if(id.value == "") {
    window.alert("Error: Username should be filled out.");
    id.focus();
    return false;
}
re = /^\w+$/;
if(!re.test(id.value)) {
    window.alert ("Error: Username must contain only letters, numbers and underscores.");
    id.focus();
    return false;
}

if(id.length < 6) {
    window.alert("Error: Username must contain at least 6 charecters.");
    id.focus();
    return false;
}
if(id.length > 12) {
    window.alert("Error: Username must not be greater than 12 charecters.");
    id.focus();
    return false;
}

if(password.value != cpassword.value) {
    window.alert("Error: Password and confirm password should be same.");
    password.focus();
    return false;
}

if(password.value != "") {
    if(password.length < 6) {
        window.alert("Error: Password must contain at least 6 charecters.");
        password.focus();
        return false;
    }
    if(password.length > 12) {
        window.alert("Error: Password must not be greater than 12 charecters.");
        password.focus();
        return false;
    }
    if(password.value == id.value) {
        window.alert("Error: Password must be different from UserName.");
        password.focus();
        return false;
    }
    re = /[0-9]/;
    if(!re.test(password.value)) {
        window.alert("Error: Password must contain at least one number.");
        password.focus();
        return false;
    }
    re = /[a-z]/;
    if(!re.test(password.value)) {
        window.alert("Error: Password must contain at least one lowercase letter (a-z).");
        password.focus();
        return false;
    }
    re = /[A-Z]/;
    if(!re.test(password.value)) {
        window.alert("Error: Password must contain at least one uppercase letters (A-Z).");
        password.focus();
        return false;
    }
}else {
    window.alert("Error: Please check that you've entered your Password.");
    password.focus();
    return false;
}

if (id.value || password.value ! valid) {
    window.alert("The username and/or password are invalid. Please try again");
    id.focus();
    return false;
}
}

</script>
</head>
<body>
<form action="search" name="signup" onsubmit="return validateForm()">
<table cellpadding="5" align="center">
<tr>
<td colspan="2">
<p> If you are new User, please <a href="SignUp.html">SignUp</a>. If you already have an account then SignIn.</p>
</td>
 </tr>
<tr><td>Username</td>
<td><input type=text name=LoginId /></td></tr>
<tr><td>Password</td>
<td><input type=password name=LoginPassword /> </td></tr>
<tr><td colspan="2" align="center">
<input type=submit value=SignIn /></td></tr>
<tr><td colspan="2">If you forgot your password, <a href="ResetPassword"> Reset </a>your password.</td></tr>
</table>
</form>
</body>
</html>