Logo 
Search:

Javascript Forum

Ask Question   UnAnswered
Home » Forum » Javascript       RSS Feeds

plz help me in this code,what is the error

  Asked By: Ajay    Date: Jul 30    Category: Javascript    Views: 1691
  

<%@page import="java.sql.*"%>
<%@page import="java.io.*"%>
<%@page import="java.util.*"%>

<%
Connection con=null;
Statement st=null;
ResultSet rt=null;

ArrayList<String> loginid=new ArrayList<String>();
ArrayList<String> loginpwd=new ArrayList<String>();
ArrayList<Integer> status =new ArrayList<Integer>();
try
{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/bank","root","root");
st=con.createStatement();

rt=st.executeQuery("select loginid,loginpwd,status from login");
while(rt.next())
{
loginid.add(rt.getString("loginid"));
loginpwd.add(rt.getString("loginpwd"));
status.add(rt.getInt("status"));
}
rt.close();

st.close();
con.close();
}
catch(Exception e)
{
out.print(e);
}

%>




<html>
<script type="text/javascript">
function checkbeforesubmit()
{
var js=0;
var loginid=document.getElementById("loginid").value;
var loginid=document.getElementById("loginpwd").value;

<%
for(int loop=0;loop<loginid.size();loop++)
{%>

if(loginid=="<%=loginid.get(loop)%>")
{
js++;
if(loginpwd=="<%=loginpwd.get(loop)%>")
{
if(<%=status.get(loop)%>==0)
{
return true;
}
else
{
alert("user already logined");
return false;
}
}
else
{
alert("invalid password");
document.getElementById("loginpwd").focus();
return false;
}
}


<%}%>
if(js==0)
{
alert("invalid login id");
document.getElementById("loginid").focus();
return false;
}

var conf= confirm("Are you sure you want to continue");
if(conf==false)
{
return false;
}

return true;
}
</script>

<body>
<form method="post" action="login" onSubmit="return checkbeforesubmit()" >

<h1 align="center" valign="middle">WELCOME TO PNB BANK</h1>
<table align="center" cellpadding="20" cellspacing="10">
<tr align="center" valign="middle">
<td>enter login id</td>
<td><input name="loginid" type="text" id="loginid" value="" maxlength="30"></td>
</tr>
<tr align="center" valign="middle">
<td>enter password</td>
<td><input name="loginpwd" type="password" id="loginpwd" value="" maxlength="30"></td>
</tr>

<td align="right" valign="middle"><input name="submit" type="submit" value="submit"></td>
</tr>
</table>
</form>
</body>
</html>

Share: 

 

No Answers Found. Be the First, To Post Answer.

 
Didn't find what you were looking for? Find more on plz help me in this code,what is the error Or get search suggestion and latest updates.




Tagged: