I am trying to elicit a submission failure response (if not return a dynamically generated response) when a pdf is submitted via Adobe Reader or Foxit6 Reader. I have written code to accomplish this for Adobe, but Foxit only displays an alert box that states whether the submission was successful ("Your form submission was successful !") or not (I was unable to elicit this prompt). I'd like to manipulate the prompt's text if possible, otherwise present a message as a pdf. I even tried submitting the pdf to a non-existent url, and it still told me the submission was successful.

In the submission receiving code, I will be doing some validation & MYSQL querying and I want to be able to express any errors or redflags to the user.

As a side, I am using pdftk to create the dynamic pdf as it is already on the server and I would like to avoid using an additional library, although the process I am using does feel a bit overcomplicated.

Here's the flow:

1. User submits a pdf using a "Submit a form" bookmark with export format: HTML.
2. PHP:
* Collects the $_POST values
* Validates
* Saves to database
* Generates a response as an fdf
* A pdf with a single text field is fed the fdf using pdftk command to produce a new pdf
* Display new dynamic pdf via readfile();

My code works for Adobe, but not Foxit:

foreach($_POST as $key=>$val){
if(!$reader && strpos($key,"Content-Disposition:_form-data;_name")){
for($x=0; $x<$count; ++$x){

// validation section, redflags are added to $alert

// connect to DB and INSERT IGNORE INTO mysql query, errors added to $alert

$fdf_content="%FDF-1.2\n%????\n1 0 obj\n<< \n/FDF << /Fields [ ";
$fdf_content.="] \n/F (".$pdf.") /ID [ <".md5(time()).">\n] >> \n>> \nendobj\ntrailer\n<<\n/Root 1 0 R \n\n>>\n%%EOF\n";

if(file_exists("$path/$fdf")){echo exec("chmod 777 $path/$fdf");}

if(is_executable("$path/$fdf")){exec("unblock pdftk \"$template\" fill_form \"$fdf\" output \"$pdf\" flatten; chmod 777 \"$pdf\"");}

header('Content-type: application/pdf');
header("Content-Disposition: attachment; filename='$pdf'");