如何将HTML输入与数据库进行比较 [英] How to compare HTML input to the database

查看:143
本文介绍了如何将HTML输入与数据库进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个html登录页面,用户在其中输入名称和密码,如果用户存在login else错误,我想将名称和密码与数据库进行比较。数据库使用mysql。



我尝试过:



#servlet page

试试

{

Class.forName(sun.jdbc.odbc.jdbcodbcdriver);

System.out.println(loading loaded );

Connection.con = DriverManager(jdbc:odbc:five);

System.out.println(数据库加载);

PreparedStatement ps = con.preparedStatement(从表中选择名称);

结果rs = ps.executQuery();

String s = JTextField.getText();

String s1 = rs.getString(name);

If(s.equals(s1)){

Matched


}

else {

无效用户;

}

}

#html页



名称

I created a html login page in which user enter the name and password and I want to compare the name and password to the database for existance if user exist the login else error.for database use mysql.

What I have tried:

#servlet page
Try
{
Class.forName("sun.jdbc.odbc.jdbcodbcdriver");
System.out.println("driver loaded");
Connection.con=DriverManager("jdbc:odbc:five");
System.out.println(database loaded);
PreparedStatement ps=con.preparedStatement("select name from table");
Results rs=ps.executQuery();
String s=JTextField.getText();
String s1= rs.getString("name");
If(s.equals(s1)){
Matched

}
else{
Invalid user;
}
}
#html page

Name

推荐答案

什么不是rk是什么意思?请记住,我们无法看到您的屏幕或猜测您做了什么。你需要展示你的代码并准确解释发生了什么。



你应该首先阅读简单安全密码认证解释 [ ^ ]以确保您安全地存储密码。另请查看 bobby-tables.com:防止SQL注入的指南 [ ^ ],以确保您保护数据库的完整性。
What does "not work" mean? Please remember, we cannot see your screen or guess what you have done. You need to show your code and explain exactly what is happening.

You should start by reading Secure Password Authentication Explained Simply[^] to ensure you are storing your passwords securely. Also check bobby-tables.com: A guide to preventing SQL injection[^] to see that you are protecting the integrity of your database.


这篇关于如何将HTML输入与数据库进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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