
how we direct page after cheching one checkbox and press login button

Hi Friend,
Try the following code:
1)login.jsp:
<html>
<script>
function validate(){
var username=document.form.user.value;
var password=document.form.pass.value;
if(username==""){
alert("Enter Username!");
return false;
}
if(password==""){
alert("Enter Password!");
return false;
}
if (!document.form.check.checked ){
alert("Please Select checkbox");
return false;
}
return true;
}
</script>
<form name="form" method="post" action="check.jsp" onsubmit="javascript:return validate();">
<table>
<tr><td>Username:</td><td><input type="text" name="user"></td></tr>
<tr><td>Password:</td><td><input type="password" name="pass"></td></tr>
<tr><td><input type="checkbox" name="check" id="check"></td><td><input type="submit" value="Login"></td></tr>
</table>
</form>
</html>
2)check.jsp:
<%@page import="java.sql.*"%>
<%
String user=request.getParameter("user");
String pass=request.getParameter("pass");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:student");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from login where uname='"+user+"' and password='"+pass+"'");
int count=0;
while(rs.next())
{
count++;
}
if(count>0)
{
out.println("welcome "+user);
}
else
{
response.sendRedirect("login.jsp");
}
%>
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.