title: Delete files from server and database (PHP)
body: <p>I have a very basic file uploading page. 
  If you are logged in, you see a page (myFiles.php) where I have a table of files uploaded by the user that's logged in + a delete button for each row. I get the user files from my database, where I have a table Uploads(filename, extension, filemtime, username) with this code:</p>
  
  <pre><code> if ($_SESSION['active'] == true) {
                  echo "&lt;table class='table'&gt;
                      &lt;tr&gt;
                      &lt;th&gt;File name&lt;/th&gt;
                      &lt;th&gt;Added&lt;/th&gt;
                      &lt;th&gt;&lt;/th&gt;
                      &lt;/tr&gt;";
                  $query = "SELECT filename, filemtime, username FROM Uploads WHERE username='".$active."' ORDER BY filemtime"; //
                  $result = mysql_query($query);
  
                  while($row = mysql_fetch_array($result,  MYSQL_ASSOC)) {
                      $timestamp = strtotime($row["filemtime"]);
                      echo "&lt;tr&gt;&lt;td&gt;" . $row["filename"]. "&lt;/td&gt;&lt;td&gt;" . date("d.m.Y",$timestamp). "&lt;/td&gt;";
                      echo "&lt;td&gt;&lt;form role='form' action='delete_check.php' method='post' enctype='multipart/form-data'&gt;";
                      echo "&lt;button type='submit' class='btn btn-default'&gt;Delete&lt;/button&gt;&lt;/form&gt;&lt;/td&gt;";
                      echo "&lt;/tr&gt;";
                  }
  
                  echo "&lt;/table&gt;";
  }
  </code></pre>
  
  <p>I need to know how can I connect the delete button to that certain row and how to pass arguments (filename and extension) to the page where I delete the file from database and my server (page delete_check.php).</p>
  
  <p>delete_check.php looks currently like this (this isn't working because I can't pass the arguments from delete.php):</p>
  
  <pre><code>    session_start();
      $active = $_SESSION['active'];
  
      $con = mysql_connect("database","user","pw");
      if (!$con) {
          die('Could not connect: ' . mysql_error());
      }
      mysql_select_db("database", $con);
  
  
      $file = "upload/".$filename.".".$extension;
      unlink($filename);
  
      $query = "DELETE FROM Uploads WHERE filename='".$filename."'";
      $delete = MYSQL_QUERY($query);
      if ($delete === true ) {
          echo "Deleted from database ".$filename." extension: " . $extension;
      } else {
          echo "Not deleted ".$filename." extension: " . $extension;
      }
      //header("Location: index.php");
  </code></pre>