title: Value of $_GET Superglobal Not Being Passed To Processing Page
body: <p>Ultimately I am trying to delete an admin by id. I know the id of the admins are making it to the list admins page because I am printing the admin id in the table next to each admin username and seeing the id.  But when the delete admin link is clicked, the delete admin page is not receiving the id from the GET superglobal. </p>
  
  <p>Why not?
  Thanks,
  CM </p>
  
  <p>list_admins.php (contains the delete button at the bottom for deleting an admin)</p>
  
  <pre><code>&lt;?php require_once("../../includes/initialize.php"); ?&gt;
  &lt;?php //if (!$session-&gt;is_logged_in()) {redirect_to("login.php");} ?&gt;
  &lt;?php confirm_logged_in(); ?&gt;
  
  &lt;?php
    $admin_set = User::find_all();
    $message = "";
  ?&gt;
  
  &lt;?php $layout_context = "admin"; ?&gt;
  &lt;?php include("../layouts/admin_header.php"); ?&gt;
  &lt;div id="main"&gt;
    &lt;div id="navigation"&gt;
          &lt;br /&gt;
          &lt;a href="index.php"&gt;&amp;laquo; Main menu&lt;/a&gt;&lt;br /&gt;
    &lt;/div&gt;
    &lt;div id="page"&gt;
      &lt;?php echo output_message($message); ?&gt;
      &lt;h2&gt;Manage Admins&lt;/h2&gt;
      &lt;table style="border: 1px solid #000; color:#000;"&gt;
        &lt;tr&gt;
          &lt;th style="text-align: left; width: 200px;"&gt;Username&lt;/th&gt;
          &lt;th style="text-align: left; width: 200px;"&gt;User Id&lt;/th&gt;
          &lt;th colspan="2" style="text-align: left;"&gt;Actions&lt;/th&gt;
        &lt;/tr&gt;
      &lt;?php foreach($admin_set as $admin) : ?&gt;
        &lt;tr&gt;
          &lt;td&gt;&lt;?php echo $admin-&gt;username; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo $admin-&gt;id; ?&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href="edit_admin.php?id=&lt;?php $admin-&gt;id; ?&gt;"&gt;Edit&lt;/a&gt;&lt;/td&gt;
          &lt;td&gt;&lt;a href="delete_admin.php?id=&lt;?php $admin-&gt;id; ?&gt;" onclick="return confirm('Are you sure you want to delete &lt;?php echo $admin-&gt;id?&gt;?');"&gt;Delete&lt;/a&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;?php endforeach ?&gt;
      &lt;/table&gt;
      &lt;br /&gt;
      &lt;a href="new_admin.php"&gt;Add new admin&lt;/a&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;?php include("../layouts/footer.php"); ?&gt;
  </code></pre>
  
  <p>delete_admin.php</p>
  
  <pre><code>&lt;?php require_once("../../includes/initialize.php"); ?&gt;
  &lt;?php if (!$session-&gt;is_logged_in()) { redirect_to("login.php"); } ?&gt;
  
  &lt;?php
    //$admin_set = User::find_all();//This works, var_dump shows me the users are 
      //being returned
    //var_dump($admin_set);
  
    $admin = User::find_by_id($_GET['id']);//This returns database query failed.
    var_dump($admin);
  ?&gt;
  </code></pre>
  
  <p>user.php</p>
  
  <pre><code>&lt;?php
  // If it's going to need the database, then it's 
  // probably smart to require it before we start.
  require_once(LIB_PATH.DS.'database.php');
  
  class User extends DatabaseObject {
  
      protected static $table_name="admins";
      protected static $db_fields = array('id', 'username', 'password', 'first_name', 'last_name');
  
      public $id;
      public $username;
      public $password;
      public $first_name;
      public $last_name;
  
    public function full_name() {
      if(isset($this-&gt;first_name) &amp;&amp; isset($this-&gt;last_name)) {
        return $this-&gt;first_name . " " . $this-&gt;last_name;
      } else {
        return "";
      }
    }
  
      public static function authenticate($username="", $password="") {
      global $database;
      $username = $database-&gt;escape_value($username);
      $password = $database-&gt;escape_value($password);
  
      $sql  = "SELECT * FROM users ";
      $sql .= "WHERE username = '{$username}' ";
      $sql .= "AND password = '{$password}' ";
      $sql .= "LIMIT 1";
      $result_array = self::find_by_sql($sql);
          return !empty($result_array) ? array_shift($result_array) : false;
      }
  
      // Common Database Methods
      public static function find_all() {
          return self::find_by_sql("SELECT * FROM ".self::$table_name);
    }
  
    public static function find_by_id($id=0) {
      $result_array = self::find_by_sql("SELECT * FROM ".self::$table_name." WHERE id={$id} LIMIT 1");
          return !empty($result_array) ? array_shift($result_array) : false;
    }
  
    public static function find_by_sql($sql="") {
      global $database;
      $result_set = $database-&gt;query($sql);
      $object_array = array();
      while ($row = $database-&gt;fetch_array($result_set)) {
        $object_array[] = self::instantiate($row);
      }
      return $object_array;
    }
  
      public static function count_all() {
        global $database;
        $sql = "SELECT COUNT(*) FROM ".self::$table_name;
      $result_set = $database-&gt;query($sql);
        $row = $database-&gt;fetch_array($result_set);
      return array_shift($row);
      }
  
      private static function instantiate($record) {
          // Could check that $record exists and is an array
      $object = new self;
          // Simple, long-form approach:
          // $object-&gt;id              = $record['id'];
          // $object-&gt;username    = $record['username'];
          // $object-&gt;password    = $record['password'];
          // $object-&gt;first_name = $record['first_name'];
          // $object-&gt;last_name   = $record['last_name'];
  
          // More dynamic, short-form approach:
          foreach($record as $attribute=&gt;$value){
            if($object-&gt;has_attribute($attribute)) {
              $object-&gt;$attribute = $value;
            }
          }
          return $object;
      }
  
      private function has_attribute($attribute) {
        // We don't care about the value, we just want to know if the key exists
        // Will return true or false
        return array_key_exists($attribute, $this-&gt;attributes());
      }
  
      protected function attributes() { 
          // return an array of attribute names and their values
        $attributes = array();
        foreach(self::$db_fields as $field) {
          if(property_exists($this, $field)) {
            $attributes[$field] = $this-&gt;$field;
          }
        }
        return $attributes;
      }
  
      protected function sanitized_attributes() {
        global $database;
        $clean_attributes = array();
        // sanitize the values before submitting
        // Note: does not alter the actual value of each attribute
        foreach($this-&gt;attributes() as $key =&gt; $value){
          $clean_attributes[$key] = $database-&gt;escape_value($value);
        }
        return $clean_attributes;
      }
  
      public function save() {
        // A new record won't have an id yet.
        return isset($this-&gt;id) ? $this-&gt;update() : $this-&gt;create();
      }
  
      public function create() {
          global $database;
          // Don't forget your SQL syntax and good habits:
          // - INSERT INTO table (key, key) VALUES ('value', 'value')
          // - single-quotes around all values
          // - escape all values to prevent SQL injection
          $attributes = $this-&gt;sanitized_attributes();
        $sql = "INSERT INTO ".self::$table_name." (";
          $sql .= join(", ", array_keys($attributes));
        $sql .= ") VALUES ('";
          $sql .= join("', '", array_values($attributes));
          $sql .= "')";
        if($database-&gt;query($sql)) {
          $this-&gt;id = $database-&gt;insert_id();
          return true;
        } else {
          return false;
        }
      }
  
      public function update() {
        global $database;
          // Don't forget your SQL syntax and good habits:
          // - UPDATE table SET key='value', key='value' WHERE condition
          // - single-quotes around all values
          // - escape all values to prevent SQL injection
          $attributes = $this-&gt;sanitized_attributes();
          $attribute_pairs = array();
          foreach($attributes as $key =&gt; $value) {
            $attribute_pairs[] = "{$key}='{$value}'";
          }
          $sql = "UPDATE ".self::$table_name." SET ";
          $sql .= join(", ", $attribute_pairs);
          $sql .= " WHERE id=". $database-&gt;escape_value($this-&gt;id);
        $database-&gt;query($sql);
        return ($database-&gt;affected_rows() == 1) ? true : false;
      }
  
      public function delete() {
          global $database;
          // Don't forget your SQL syntax and good habits:
          // - DELETE FROM table WHERE condition LIMIT 1
          // - escape all values to prevent SQL injection
          // - use LIMIT 1
        $sql = "DELETE FROM ".self::$table_name;
        $sql .= " WHERE id=". $database-&gt;escape_value($this-&gt;id);
        $sql .= " LIMIT 1";
        $database-&gt;query($sql);
        return ($database-&gt;affected_rows() == 1) ? true : false;
  
          // NB: After deleting, the instance of User still 
          // exists, even though the database entry does not.
          // This can be useful, as in:
          //   echo $user-&gt;first_name . " was deleted";
          // but, for example, we can't call $user-&gt;update() 
          // after calling $user-&gt;delete().
      }
  
  }
  
  ?&gt;
  </code></pre>
  
  <p>database.php</p>
  
  <pre><code>&lt;?php 
  require_once(LIB_PATH.DS."config.php");
  
  class MySQLDatabase{
      private $connection;
  
      function __construct(){
          $this-&gt;open_connection();
      }
  
      public function open_connection(){
      $this-&gt;connection = mysqli_connect(DB_SERVER, DB_USER, DB_PASS,DB_NAME);
          if(mysqli_connect_errno()) {
            die("Database connections failed: " . 
                 mysqli_connect_error() . 
                 " (" . mysqli_connect_errno() . ")"
            );
          }
      }
  
      public function close_connection(){
          if(isset($this-&gt;connection)){
              mysqli_close($this-&gt;connection);
              unset($this-&gt;connection);
          }
      }
  
      public function query($sql){
          $result = mysqli_query($this-&gt;connection, $sql);
          $this-&gt;confirm_query($result);
          return $result;
      }
  
      private function confirm_query($result_set) {
  
          if (!$result_set) {
              die("Database query failed yo.");
          }
      }
  
      public function escape_value($string) {
      $escaped_string = mysqli_real_escape_string($this-&gt;connection, $string);
      return $escaped_string;
  }
  //database neutral functions
      public function fetch_array($result_set){
          return mysqli_fetch_array($result_set);
      }
  
      public function num_rows($result_set){
          return mysqli_num_rows($result_set);
      }
  
      public function insert_id(){
          return mysqli_insert_id($this-&gt;connection);
      }
  
      public function affected_rows(){
          return mysqli_affected_rows($this-&gt;connection);
      }
  }//End class MySQLDatabase
  $database = new MySQLDatabase();
  ?&gt;
  </code></pre>