title: Javascript Alert Box (Stay on same page)?
body: <p>I'm creating a download page in PHP, which will display an alert box in Javascript IF the download file does not exist (when the user clicks a button for the corresponding product).</p>
  
  <p>The PROBLEM is, once the user hits OK on the alert box, it navigates away from the current page (that lists the downloads). I want it to STAY on the same page with the SAME content to be displayed.</p>
  
  <p>Full code:</p>
  
  <pre><code>&lt;?php
  $product = $_GET["p"];
  $ChangeFileName = "";
  
  if ($product == 'Product1')
  {
      $realFileName = "OriginalFileName.exe";
      $ChangeFileName = "NewFileNameHere.exe";
  }
  elseif ($product == 'Product2')
  {
      $realFileName = "OriginalFileName.exe";
      $ChangeFileName = "NewFileNameHere.exe";
  }
  else
  {
      echo '&lt;script type="text/javascript"&gt;
      alert("Sorry, there is no download available for this product! Please contact support.");
      &lt;/script&gt;';
      exit;
  }
  
  $file = "downloads/".$realFileName;
  $fp = fopen($file, 'rb');
  
  header("Content-Type: application/octet-stream");
  header("Content-Disposition: attachment; filename=$ChangeFileName");
  header("Content-Length: " . filesize($file));
  fpassthru($fp);
  ?&gt;
  exit;
  </code></pre>