title: using GET function to link pages
body: <p>I have a login scrip (downloaded from the internet) that i have adapted to my database. i However have a problem with linking from the login to a page in my system with details of the user that has logged in.</p>
  
  <p>The users table on which the login system is based has the following fields</p>
  
  <pre><code>`id` int(11) NOT NULL AUTO_INCREMENT,  
  `username` varchar(18) NOT NULL,  
  `first_name` varchar(32) NOT NULL,  
  `last_name` varchar(32) NOT NULL,  
  `gender` varchar(15) NOT NULL DEFAULT 'undisclosed',  
  `bio` text NOT NULL,  
  `image_location` varchar(125) NOT NULL DEFAULT 'avatars/default_avatar.png',  
  `password` varchar(512) NOT NULL,  
  `email` varchar(1024) NOT NULL,  
  `email_code` varchar(100) NOT NULL,  
  `time` int(11) NOT NULL,  
  `confirmed` int(11) NOT NULL DEFAULT '0',  
  `generated_string` varchar(35) NOT NULL DEFAULT '0',  
  `ip` varchar(32) NOT NULL,  
  `EmployeeID` int(11) DEFAULT '0',  
  PRIMARY KEY (`id`)
  </code></pre>
  
  <p>The table that holds the user details has among other the following fields</p>
  
  <pre><code>CREATE TABLE IF NOT EXISTS `chidren` (
   `ChildID` int(11) NOT NULL AUTO_INCREMENT,
   `EmployeeID` int(11) DEFAULT '0',
   `ChildName` varchar(50) DEFAULT NULL,
   `DateOfBirth` datetime DEFAULT NULL,
   `Mother` varchar(50) DEFAULT NULL,
   `Comment` longtext,
   `Clerk` varchar(50) DEFAULT NULL,
   `Picture` longblob,
   `Pic` longblob,
   PRIMARY KEY (`ChildID`),
   KEY `ChildID` (`ChildID`),
   KEY `EmployeeID` (`EmployeeID`)
  </code></pre>
  
  <p>As you can note the two tables are connected using the EmployeeID field.</p>
  
  <p>The login script from which the user will be directed to his/her page is this</p>
  
  <pre><code>&lt;?php
  require 'core/init.php';
  $general-&gt;logged_in_protect();
  
  if (empty($_POST) === false) {
  
      $username = trim($_POST['username']);
      $password = trim($_POST['password']);
  
      if (empty($username) === true || empty($password) === true) {
          $errors[] = 'Sorry, but we need your username and password.';
      } else if ($users-&gt;user_exists($username) === false) {
          $errors[] = 'Sorry that username doesn\'t exists.';
      } else if ($users-&gt;email_confirmed($username) === false) {
          $errors[] = 'Sorry, but you need to activate your account. 
                       Please check your email.';
      } else {
          if (strlen($password) &gt; 18) {
              $errors[] = 'The password should be less than 18 characters, without spacing.';
          }
          $login = $users-&gt;login($username, $password);
          if ($login === false) {
              $errors[] = 'Sorry, that username/password is invalid';
          }else {
              session_regenerate_id(true);// destroying the old session id and creating a new one
              $_SESSION['id'] =  $login;
              header('Location: home.php');
              exit();
          }
      }
  } 
  ?&gt;
  &lt;!doctype html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/style.css" &gt;
      &lt;title&gt;Login&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;  
      &lt;div id="container"&gt;
      &lt;?php include 'includes/menu.php'; ?&gt;
  
          &lt;h1&gt;Login&lt;/h1&gt;
  
          &lt;?php 
          if(empty($errors) === false){
              echo '&lt;p&gt;' . implode('&lt;/p&gt;&lt;p&gt;', $errors) . '&lt;/p&gt;';  
          }
          ?&gt;
  
          &lt;form method="post" action=""&gt;
              &lt;h4&gt;Username:&lt;/h4&gt;
              &lt;input type="text" name="username" value="&lt;?php if(isset($_POST['username'])) echo htmlentities($_POST['username']); ?&gt;" /&gt;
              &lt;h4&gt;Password:&lt;/h4&gt;
              &lt;input type="password" name="password" /&gt;
              &lt;br&gt;
              &lt;input type="submit" name="submit" /&gt;
          &lt;/form&gt;
          &lt;br&gt;
          &lt;a href="confirm-recover.php"&gt;Forgot your username/password?&lt;/a&gt;
  
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The home page that came with the login script is this (i have included this just in case it helps to solve my problem)</p>
  
  <pre><code>  &lt;?php 
      require 'core/init.php';
      $general-&gt;logged_out_protect();
  
      $username   = htmlentities($user['username']); // storing the user's username after clearning for any html tags.
  
      ?&gt;
      &lt;!doctype html&gt;
      &lt;html lang="en"&gt;
      &lt;head&gt;
      &lt;meta charset="UTF-8"&gt;
      &lt;link rel="stylesheet" type="text/css" href="css/style.css" &gt;
      &lt;title&gt;Home&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;  
      &lt;div id="container"&gt;
          &lt;?php include 'includes/menu.php'; ?&gt;
          &lt;h1&gt;Hello &lt;?php echo $username, '!'; ?&gt;&lt;/h1&gt;
      &lt;/div&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <hr>
  
  <p>and here is my page which unfortunately is failing.</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;link rel="stylesheet" type="text/css" href="mystyle.css" /&gt;
          &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;?php
  require 'core/init.php';
      $general-&gt;logged_out_protect();
  
      // query db and get date only for the user that logged in. Used GROUP BY because one employee will have more than one child 
      $EmployeeID = $_GET['EmployeeID'];
      $result = mysql_query("SELECT * FROM children WHERE EmployeeID=$EmployeeID
      GROUP BY holder.EmployeeID")
  
      or die(mysql_error());
  
      // display data in table
  
          echo "&lt;table border='1' cellpadding='10'&gt;";
          echo "&lt;tr&gt; &lt;th&gt;Child Name&lt;/th&gt; &lt;th&gt;Mother&lt;/th&gt; &lt;th&gt;Date of Birth&lt;/th&gt;  ";
  
      while($row = mysql_fetch_array( $result )) {
  
      // echo out the contents of each row into a table
      echo "&lt;tr&gt;";
      //echo '&lt;td&gt;' . $row['EmployeeID'] . '&lt;/td&gt;';
      echo '&lt;td&gt;' . $row['ChildName'] . '&lt;/td&gt;';              
      echo '&lt;td&gt;' . $row['Mother'] . '&lt;/td&gt;';
      echo '&lt;td&gt;' . $row['DateOfBirth'] . '&lt;/td&gt;';
      //the following two fields link to files exactly the same as this one. Again the linking is by EmployeeID
      echo '&lt;td&gt;&lt;a href="arm/spouse.php?EmployeeID=' . $row['EmployeeID'] . '"&gt;SPOUSE DETAILS&lt;/a&gt;&lt;/td&gt;';
      echo '&lt;td&gt;&lt;a href="arm/employeedatails.php?EmployeeID=' . $row['EmployeeID'] . '"&gt;WORK DETAILS&lt;/a&gt;&lt;/td&gt;';
      echo "&lt;/tr&gt;"; 
          } 
  
          // close table&gt;
          echo "&lt;/table&gt;";
      ?&gt;
  
      &lt;p&gt;Click on any of the above to see your other details&lt;/p&gt;
      &lt;/body&gt;
      &lt;/html&gt; 
  </code></pre>
  
  <p>My problem is that I am failing to get to correctly code the page so that it can only draw data about the user that has logged in. In fact in all my tries the page is simply giving me errors and below is the code i tried for the page and i used the GET function so that the page displays only the data about the specific user. </p>
  
  <p>Before you say it, yes, I have used not used mysqli in my page (would that be the cause of the error?) but then I am completely green with mysqli and just a begginer with mysql. But I would appreciate if the help would be in mysqli since I have found out its more secure. 
  I am someone migrating from MSACCESS (I just had to migrate to place my program on the web).</p>