使用netbeans的mysql中的用户和管理员登录jsp页面 [英] user and admin login jsp page in mysql using netbeans
本文介绍了使用netbeans的mysql中的用户和管理员登录jsp页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
用户和管理员登录jsp页面
user and admin login jsp page in mysql using netbeans
推荐答案
try
{
连接con = null;
语句st = null;
语句st1 = null;
int i;
字符串连接URL ="jdbc:mysql://localhost:3306/您的数据库名称";
字符串g1 = request.getParameter("Login");
字符串s1 = request.getParameter("uname");
字符串s2 = request.getParameter("pass");
if(g1!= null)
{
字符串sql1 ="select from from userdetails",其中uname =''"+ s1 +"''和pass =''" + s2 +''";
Class.forName("com.mysql.jdbc.Driver").newInstance();
连接connection = DriverManager.getConnection(connectionURL,"root","root");
st = connection.createStatement();
ResultSet rs = st.executeQuery(sql1);
if(rs.next())
{
response.sendRedirect("UserHome.jsp");
}
其他
{
out.println(< html>< body>< script type = \" text/javascript \>");
out.println("confirm("无效的用户名或密码);");
out.println(</script></body</html>");
}
}
}
catch(Exception e)
{
out.println(e);
}
try
{
Connection con = null;
Statement st=null;
Statement st1=null;
int i;
String connectionURL = "jdbc:mysql://localhost:3306/your db name";
String g1=request.getParameter("Login");
String s1=request.getParameter("uname");
String s2=request.getParameter("pass");
if(g1!=null)
{
String sql1="select * from userdetails where uname=''"+s1+"'' and pass=''"+s2+"''";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection =DriverManager.getConnection(connectionURL,"root","root");
st=connection.createStatement();
ResultSet rs=st.executeQuery(sql1);
if(rs.next())
{
response.sendRedirect("UserHome.jsp");
}
else
{
out.println("<html><body><script type=\"text/javascript\">");
out.println("confirm(''INVALID USERNAME or PASSWORD'');");
out.println("</script></body></html>");
}
}
}
catch(Exception e)
{
out.println(e);
}
我将在哪里添加连接代码
m nt getting where i hav to add my connectivity code
try
{
Connection con = null;
Statement st=null;
Statement st1=null;
int i;
String connectionURL = "jdbc:mysql://localhost:3306/your db name";
String g1=request.getParameter("Login");
String s1=request.getParameter("uname");
String s2=request.getParameter("pass");
if(g1!=null)
{
String sql1="select * from userdetails where uname=''"+s1+"'' and pass=''"+s2+"''";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection =DriverManager.getConnection(connectionURL,"root","root");
st=connection.createStatement();
ResultSet rs=st.executeQuery(sql1);
if(rs.next())
{
response.sendRedirect("UserHome.jsp");
}
else
{
out.println("<html><body><script type=\"text/javascript\">");
out.println("confirm(''INVALID USERNAME or PASSWORD'');");
out.println("</script></body></html>");
}
}
}
catch(Exception e)
{
out.println(e);
}
这篇关于使用netbeans的mysql中的用户和管理员登录jsp页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文