title: Regarding force download of a pdf file on clicking submit button after data is stored in database
body: <p>I have used the following code to store the data in wordpress database when submit button is clicked , And right now the code works by submitting the data to the wordpress database . </p>
  
  <pre><code>   if ($_POST['subscribe_btn']) 
      {
      require("connect.php");
      $user = $_POST['user'];
      $email = $_POST['email'];
      if($user) 
      { 
      if(preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
      $query=mysql_query("SELECT * FROM wp_newslettter WHERE email='$email'") or exit(mysql_error());
      $numrows= mysql_num_rows($query);
     if($numrows == 0 )
  
      {
      mysql_query("INSERT INTO wp_newslettter (`name`,`email`) VALUES ('$user','$email')")or exit(mysql_error());
      }
      else 
      $errmsg = "email address already exists";
      }
      else
      $errmsg = "Please enter a valid email address";
     } 
  
      else 
     $errmsg = "Please enter your username";
  } 
  </code></pre>
  
  <p>what i am now trying to do is once the data has been saved to the database i would like to force download a pdf which is stored in my theme , i am really new to wordpress and am not able to access the file path , i have done the following code but no file downloads , pls any help regarding this will be grateful and my form action is as follows <code>action='$_SERVER[REQUEST_URI]'</code></p>
  
  <p>/<strong>**Code For downloading pdf after data submission *</strong>/ </p>
  
  <pre><code>$a =  bloginfo('template_url');
  $file= $a . "/pdf/default.pdf";
  
  $path_parts = pathinfo($file);
  $ext = strtolower($path_parts["extension"]); 
  switch ($ext) {
    case "pdf": $ctype="application/pdf"; break;
    case "exe": $ctype="application/octet-stream"; break;
    case "zip": $ctype="application/zip"; break;
    case "doc": 
    case "docx":  $ctype="application/msword"; break;
    case "xls": $ctype="application/vnd.ms-excel"; break;
    case "ppt": $ctype="application/vnd.ms-powerpoint"; break;
    case "gif": $ctype="image/gif"; break;
    case "png": $ctype="image/png"; break;
    case "jpeg":
    case "jpg": $ctype="image/jpg"; break;
    default: $ctype="application/force-download";
  } 
  header('Content-Description: File Transfer');
  header('Content-Type: application/force-download');
  header("Content-type:  $ctype"); 
  header('Content-Disposition: attachment; filename='.basename($file));
  header('Content-Transfer-Encoding: binary');
  header('Expires: 0');
  header('Cache-Control: must-revalidate , post-check=0, pre-check=0');
  header('Pragma: public');
  header('Content-Length: ' . filesize($file));
  ob_clean();
  flush();
  readfile($file);
  exit;
  </code></pre>
  
  <p>I am unable to read the file by doing the following code </p>