prob.. in login page


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: prob.. in login page

  1. #1
    Join Date
    Nov 2004
    Posts
    29

    prob.. in login page

    hi..all of u....

    i have made a login page in html page...in which two text field there..named username and password...

    i want to do the stuff that if the user enter correct username and password..then it displays a pop up window mentioning that u have successfully enetered and it then directly went into the mypage.jsp page...(targeted page)

    and if users enter wrong entry then it displays error in another page..

    plz... do the needful for me....i am not getting any thing....

    my code is as follow:


    try
    {

    String Username = request.getParameter("msno");
    String Password = request.getParameter("pass");

    sql = conn.prepareStatement("SELECT * FROM login_mast WHERE name = '" + Username + "' and password='"+Password+"' ");

    results = sql.executeQuery();

    while(results.next())
    {

    String Dbname = results.getString("name");
    String Dbpassword = results.getString("password");


    out.println("<TABLE >");
    out.println("<TR>");
    out.println("<TD><strong>Username</strong>:</TD>");
    out.println("<TD><strong>Password</strong>:</TD></TR>");

    out.println("<tr><td> <INPUT TYPE='TEXT' size='5' value='" + Dbname + "' readonly </td>");
    out.println("<td> <INPUT TYPE='TEXT' size='5' value='" + Dbpassword + "' readonly </td></tr>");
    }
    }
    catch (SQLException s)

  2. #2
    Join Date
    Oct 2004
    Posts
    11
    don't you have to connect to the database before you start executing SQL statments?

  3. #3
    Join Date
    Oct 2004
    Posts
    311
    The reason you don't see anything on the screen is fairly simple (if I'm correct). You always execute the SQL statement (I'm assuming you have made the database connection in an earlier part of the code not included here). However, you only print the login page when you actually find something in the dabase. Which is not going to happen before the user submits his username / password.
    You should put the out.println piece outside the while (rs.next()) loop, this way, this part of the code will always be executed and thus the user will always see the login page.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center