title: Record user's ip address everytime user loggin in - PHP
body: <p>Here are my codes from the login page. I want to be able to count how many times have been using my website and also where they logged in from. I am able to do the count, but not the ipaddress.</p>
  
  <p>In the table, I want it show each user data like this</p>
  
  <p>These are the columns in my table. USERNAME, LAST LOGGED IN, TIMES LOGGING IN, IPADDRESS, IPADDRESS1, IPADDRESS, ...... IPADDRESS10. I have created all 10 different ip address columns ( I am not really sure how to make the followings looks like they are in the table, so I am really sorry )</p>
  
  <p>USERNAME  |    LAST LOGGED IN    |  TIMES LOGGING IN  |   IPADDRESS   |  IPADDRESS1   |  IPADDRESS2 ......  |  IPADDRESS10</p>
  
  <p>IHOP      |  21-12-2012 8.59PM   |         5          |  80.81.82.83  |  80.81.82.82  |  80.81.82.83</p>
  
  <p>Every time a new ip address was used to log in from the same user, the ip address will be record into the table. Each user has up to 10 different ip addresses. The table is from my first thought, so I am not really sure if it's the best way to show them in the table or not, so please also give me a recommendation. </p>
  
  <p>How do I add these ip addresses in to the table? I am not really sure how to separate each ip address column. When I got the new ip address, it just keeps overwriting the old ip address.</p>
  
  <p>Thank you very much.</p>
  
  <pre><code>var $HOST = "website.com";  
  var $USERNAME = "username"; 
  var $PASSWORD = "password"; 
  var $DBNAME = "database";   
  
  function authenticate($username, $password) {
  
  $Auth = new auth();
  $detail = $Auth-&gt;authenticate($username, $password);
  
      if (ereg("'", $username)) 
      {
          return "invalid username";
      }
  
      if (ereg("'", $password)) 
      {
          return "invalid password";
      }
  
      $query = "SELECT * FROM user WHERE uname='$username' AND passwd=MD5('$password') AND status &lt;&gt; 'inactive'";
  
      $UpdateRecords = "UPDATE user SET lastlogin = NOW(), logincount = logincount + 1 WHERE uname='$username'";
      $connection = mysql_connect($this-&gt;HOST, $this-&gt;USERNAME, $this-&gt;PASSWORD);
  
      $SelectedDB = mysql_select_db($this-&gt;DBNAME);
      $result = mysql_query($query); 
  
      $numrows = mysql_num_rows($result);
      $row = mysql_fetch_array($result);
  
      if ($numrows == 0) {
          return 0;
      }
  
      */
      else {
          $Update = mysql_query($UpdateRecords);
          return $row;
      }
  </code></pre>