Index: server/DataAccess.cpp
===================================================================
--- server/DataAccess.cpp	(revision 87b3ee2526ba9b73d93862e48b4d519434148b39)
+++ server/DataAccess.cpp	(revision 41ad8ed6bf5a6a22991206566960ac4dfd83c276)
@@ -43,5 +43,8 @@
    result = select("users", oss.str().c_str());
 
+   cout << "Got result" << endl;
+
    if (result == NULL) {
+      cout << "Error occured" << endl;
       cout << mysql_error(connection) << endl;
       return NULL;
@@ -50,6 +53,8 @@
    if ( ( row = mysql_fetch_row(result)) != NULL )
       p = new Player(string(row[1]), string(row[2]));
-   else
+   else {
+      cout << "Returned no results for some reason" << endl;
       p = NULL;
+   }
 
    mysql_free_result(result);
Index: server/Player.cpp
===================================================================
--- server/Player.cpp	(revision 87b3ee2526ba9b73d93862e48b4d519434148b39)
+++ server/Player.cpp	(revision 41ad8ed6bf5a6a22991206566960ac4dfd83c276)
@@ -27,12 +27,4 @@
 }
 
-// was meant for the find find function. Currently unused
-bool Player::operator == (const Player &p)
-{
-   bool eq = addr.sin_addr.s_addr == p.addr.sin_addr.s_addr;
-
-   return eq;
-}
-
 void Player::setAddr(sockaddr_in addr)
 {
Index: server/Player.h
===================================================================
--- server/Player.h	(revision 87b3ee2526ba9b73d93862e48b4d519434148b39)
+++ server/Player.h	(revision 41ad8ed6bf5a6a22991206566960ac4dfd83c276)
@@ -13,6 +13,4 @@
    ~Player();
 
-   bool operator == (const Player &p);
-
    void setAddr(sockaddr_in addr);
 
Index: server/server.cpp
===================================================================
--- server/server.cpp	(revision 87b3ee2526ba9b73d93862e48b4d519434148b39)
+++ server/server.cpp	(revision 41ad8ed6bf5a6a22991206566960ac4dfd83c276)
@@ -25,21 +25,4 @@
 #include "../common/message.h"
 
-/*
- Protocol Design
-
- Client sends a login message
- Server replies with client's position in the world and positions of
- oall other logged in players
- Merver sends player ids along with locations
- This means a newly logged in client will need to know which id is
- assigned to it
- So server needs to send an id message, wait for an ack, and then send
- the location messages
- When a client shuts down, it sends a message to indicate this so the
- server can remove it from the list of connected clients
- Eventually, there'll need to be a way to detect timeouts from clients
- (if they crashed or otherwise failed to send the logout message)
-*/
-
 using namespace std;
 
@@ -57,10 +40,14 @@
    vector<Player>::iterator it;
 
+   cout << "Entered findPlayerByName" << endl;
+
    for (it = vec.begin(); it != vec.end(); it++)
    {
+      cout << "Comparing name" << endl;
       if ( it->name.compare(name) == 0 )
          return &(*it);
    }
 
+   cout << "About to return" << endl;
    return NULL;
 }
@@ -110,25 +97,5 @@
       exit(1);
    }
-
-   /*
-   DataAccess da;
-
-   da.printPlayers();
-
-   da.insertPlayer("playerName3", "playerPass");
-   cout << endl << "Inserted player" << endl << endl;
-
-   Player* p = da.getPlayer("playerName");
-   cout << "player name: " << p->name << endl;
-   delete(p);
-
-   p = da.getPlayer("playerName3");
-   cout << "player name: " << p->name << endl;
-   delete(p);
-
-   da.printPlayers();
-   cout << endl;
-   */
-   
+ 
    sock = socket(AF_INET, SOCK_DGRAM, 0);
    if (sock < 0) error("Opening socket");
@@ -168,4 +135,6 @@
 void processMessage(const NETWORK_MSG &clientMsg, const struct sockaddr_in &from, vector<Player> &vctPlayers, int &num, NETWORK_MSG &serverMsg)
 {
+   DataAccess da;
+
    cout << "ip address: " << inet_ntoa(from.sin_addr) << endl;
    cout << "port: " << from.sin_port << endl;
@@ -185,5 +154,7 @@
          cout << "password: " << password << endl;
 
-         strcpy(serverMsg.buffer, "Registration test");
+         da.insertPlayer(username, password);
+
+         strcpy(serverMsg.buffer, "Registration successful");
 
          serverMsg.type = MSG_TYPE_REGISTER;
@@ -194,9 +165,23 @@
       {
          string username(clientMsg.buffer);
+         string password(strchr(clientMsg.buffer, '\0')+1);
          cout << "Player logging in: " << username << endl;
 
-         Player *p = findPlayerByName(vctPlayers, username);
-
-         if (p == NULL)
+         Player* p = da.getPlayer(username);
+
+         if (p == NULL || p->password != password)
+         {
+            if (p != NULL)
+            {
+               cout << "p->password: " << p->password << endl;
+               cout << "password: " << password << endl;
+            }
+            strcpy(serverMsg.buffer, "Incorrect username or password");
+         }
+         else if(findPlayerByName(vctPlayers, username) != NULL)
+         {
+            strcpy(serverMsg.buffer, "Player has already logged in.");
+         }
+         else
          {
             Player newP(username, "");
@@ -206,10 +191,8 @@
             strcpy(serverMsg.buffer, "I'm thinking of a number between 1 and 1000. Guess what it is.");
          }
-         else
-         {
-            strcpy(serverMsg.buffer, "Player has already logged in.");
-         }
 
          serverMsg.type = MSG_TYPE_LOGIN;
+   
+         delete(p);
 
          break;
@@ -234,5 +217,5 @@
          {
             vctPlayers.erase((vector<Player>::iterator)p);
-            strcpy(serverMsg.buffer, "You have successfully logged out. You may quit the game.");
+            strcpy(serverMsg.buffer, "You have successfully logged out.");
          }
 
