hello,
I just noticed a problem in my code.
hope you'll would help me.
normally we have a login page where the userid and password is validated from database .now the problem what i am facing is

while(rs.next())
{
if((rs.getString("m_emp_no").equals(user)) && (rs.getString("m_password").equals(pwd)) )
{
" " direct to some page
}
else
{
<script language="javascript">
alert("Sorry!Wrong User ID or Password entered.Try Again");
document.f1.action="loginpage"
document.f1.submit();
}
}

now the code is working fine to log in to the main page but when i type any user id or password in the text box then it doesnt direct me to the alert box else it just shows me a blank page.for example if my password is "welcome" in database and i type "Welcome" which is in caps then it prompts me the alert box but if it type "hello123" then it doesnt prompt me the alert box.i really dont understand what is the problem.i even tried with this code

if(rs.next()==true)
{
}
else if(rs.next()==false)
{
javascript
}

here it directs me to the alert box if i put any password wrong, but here the problem is if the password column in database is in caps such as "Welcome" and in the page if i insert "welcome" in lower case still it accepts and direct me to the main page which shouldnt happen.so pls anyone could help me out of this .if the question is not clear pls ask me to send it again.
thanks in advance.

Is there no one to help me out of this.I was expecting some help from you people.Anyways i am still waiting for the solution .if any one could help me out, it would be a great favour.
thanks

commented: 24/7service just for you -2
while(rs.next())
{
if((rs.getString("m_emp_no").equals(user)) && (rs.getString("m_password").equals(pwd)) )
{
" " direct to some page
}
else
{
<script language="javascript">
alert("Sorry!Wrong User ID or Password entered.Try Again");
document.f1.action="loginpage"
document.f1.submit();
}
}

I notice the following problems :-

  • First no indentations
  • Next I do not know where does this code go, is it inside a servlet or inside a JSP page, either way you should get an error cause you are directly mixing html with java code without appropriate delimiters
  • And the code you are using to redirect you have completely skipped it from what can be seen, which is from your description appears to be where the problem lies.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.