Click here to Skip to main content
15,902,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
user and admin login jsp page in mysql using netbeans
Posted
Updated 16-Feb-17 19:12pm
Comments
onelopez 1-Nov-12 9:31am    
Not really sure what you are attempting to ask.

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);
}
 
Share this answer
 
m nt getting where i hav to add my connectivity code
 
Share this answer
 
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);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900