Hi,

I'm trying to create a website where users can upload partypics and such. Pretty lame idea but thats not the problem. I am trying to create a login page which checks in my database if the user name and the password is correct. However the problem is that everything works great with just one user name and password in my database, but as soon as another one registers no one can login.

Here is my code.

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.DriverManager;
import java.sql.Statement;

import javax.servlet.*;
import javax.servlet.http.*;

import java.io.*;
import java.sql.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class LoggaIN extends HttpServlet {

Statement stmt;

ResultSet rs;

Connection con;


public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {

String namn = request.getParameter("user");

String losen = request.getParameter("password");





try {


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = (Connection) DriverManager.getConnection("jdbcdbc:databasen","","");
stmt = con.createStatement();
rs = (ResultSet) stmt.executeQuery("select UserName, Password from users");


while(rs.next()) {



if (!(namn.equals("null")) && (namn.equals(rs.getString("UserName"))) && (!(losen.equals("null")) && losen.equals(rs.getString("Password"))))

{
response.sendRedirect("inloggad.html");
}


else
{
response.sendRedirect("fel.html");
}
}

}



catch (Exception e) {
e.printStackTrace();
}



}
}