登录表单中密码验证的区分大小写(Case sensitivity in password validation in login form)

编程入门 行业动态 更新时间:2024-10-28 03:31:35
登录表单中密码验证的区分大小写(Case sensitivity in password validation in login form)

我有一个登录表单,我已完成连接到数据库,一切正常。 我的数据库中有一个用户名= a和密码= b。 在登录期间,如果我在密码中输入“B”,我可以登录,有人可以通过验证密码字段来帮助我。 Thx提前。 JSP代码如下:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> </head> <body bgcolor="#FFCC66"> <center> <h1>Login</h1> </center> <form action="CommonLog" method="post"> <center> <table align="center"> <tr> <td><font style="font-size: 20px">Name</font></td> <td><input type="text" name="name" style="width: 228px; height: 34px;"/></td> </tr> <tr> <td><font style="font-size: 20px">Password</font></td> <td><input type="password" name="pass" style="width: 229px; height: 36px"/></td> </tr> <tr> <td> <td><input type="submit" value="Login" style="width: 88px; height: 41px; font-size: 15px" /></td> </tr> </table> </center> </form> </body> </html>

I have a login form, i am done with connecting to DB, everything works fine. I have a username = a and password = b in my DB. During login if i enter "B" in password, i am able to login, can some one help me out with validating that password field. Thx in advance. The JSP code is as follows:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> </head> <body bgcolor="#FFCC66"> <center> <h1>Login</h1> </center> <form action="CommonLog" method="post"> <center> <table align="center"> <tr> <td><font style="font-size: 20px">Name</font></td> <td><input type="text" name="name" style="width: 228px; height: 34px;"/></td> </tr> <tr> <td><font style="font-size: 20px">Password</font></td> <td><input type="password" name="pass" style="width: 229px; height: 36px"/></td> </tr> <tr> <td> <td><input type="submit" value="Login" style="width: 88px; height: 41px; font-size: 15px" /></td> </tr> </table> </center> </form> </body> </html>

最满意答案

您的密码匹配条件可以是

直接向db发送用户名和密码,然后匹配您的数据

从表中完整地检索数据然后匹配数据。

如果您在JAVA方法中匹配数据,那么您可以使用equalsIgnoreCase 它将消除您面临的案例敏感问题。

您可以使用的第二件事是mysql Binary Operator比较中的二元运算符

你可以在mysql中搜索使用COLLATE Case感性

Your Password matching criteria can be

sending the username and password to db directly and then matching your data or

retrieving data from the table completly and then matching data.

if you're matching data in JAVA method then you can use equalsIgnoreCase it will remove case senstivity problem you are facing .

2nd thing you can use is binary operator in mysql Binary Operator comparision

you can use COLLATE Case senstivity in search in mysql

更多推荐

本文发布于:2023-07-24 20:59:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1251050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:大小写   表单   密码   Case   sensitivity

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!