Here is the initial form page:
Code: Select all
<?php
include dirname<__FILE__>.'/mod_process.php';
echo '<?xml version="1.0" encoding="iso-8859-1"?>',"\n"; // because short_open_tags = On causes a parse error.
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
</head>
<body bgcolor="#FFFFFF" onload__="MM_preloadImages<'textA.gif','closeB.jpg','closeA.jpg'>;checkFreeForm<document.getElementById<'agent_name'>>;" marginheight="0" marginwidth="0" topmargin="0" leftmargin="0">
<div id="application">
<?php
if<isset<$CREATED>>{
?>
<span class="style4">
<h1>Your Result</h1>
<p><a href="<?php echo str_replace<dirname<__FILE__>.'/','',$fdf_file> ?>">Click here to create forms package.</a> </p>
</span>
<?php
}
?>
<form method="POST" autocomplete="on" NAME="smartform" target="_parent" action="<?php echo $_SERVER['REQUEST_URI'] ?>" onsubmit__="return Validator<smartform>; clickedButton"><a NAME="tab1"></a>
<center>
<center>
<table BORDER=1 CELLSPACING=0 CELLPADDING=0 WIDTH="620" bordercolor="#003399" >
<tr>
<td bgcolor="#7C96A5">
<center>
<a NAME="tab7"></a><span class="style2"><b>BORROWER INFORMATION</b></span>
</center>
</td>
</tr>
</table>
<table border=0 width="620" align="center" >
<tr>
<td width="51">
<td width="112"> </td>
<td width="221"><span class="style4"><b> Borrower</b></span></td>
<td width="222"><span class="style4"><b> Co-Borrower</b></span></td>
</tr>
<tr>
<td width="51">
</td>
<td width="112" bgcolor="#E8EBEE">
<div align=right><span class="style4">First Name: </span></div>
</td>
<td width="221" bgcolor="#F7F7F7"> <span class="style4">
<input class="left" onblur__="mark<this,'#ffffff','#000000'>" name="b_fname" size="20" maxlength="40" onfocus__="nextfield ='cb_fname'; mark<this,'#FFFF99','#0000FF'>">
</span> </td>
<td width="222" bgcolor="#E8EBEE"> <span class="style4">
<input class="left" onblur__="mark<this,'#ffffff','#000000'>" name="cb_fname" size="20" maxlength="40" onfocus__="nextfield ='b_lname'; mark<this,'#FFFF99','#0000FF'>">
</span> </td>
</tr>
</tr>
</table>
<center>
Submission Date: <input type="date" name="creation_date" size="10">
<p><input TYPE="submit" name="submit" value="Submit" onclick__="clickedButton=true">
</center>
<p>
<p>
<input type="hidden" name="MM_insert" value="smartform">
</form>
<table width="620" border="0" cellspacing="2" cellpadding="0" align="center">
</table>
</div>
</body>
</html>
this is the file that takes the form contents and turns it into an FDF file, which is read by a PDF file:
Code: Select all
<?php
function createFDF($file,$info){
$data="%FDF-1.2\n%âãÏÓ\n1 0 obj\n<< \n/FDF << /Fields [ ";
foreach($info as $field => $val){
if(is_array($val)){
$data.='<</T('.$field.')/V[';
foreach($val as $opt)
$data.='('.trim($opt).')';
$data.=']>>';
}else{
$data.='<</T('.$field.')/V('.trim($val).')>>';
}
}
$data.="] \n/F (".$file.") /ID [ <".md5(time()).">\n] >>".
" \n>> \nendobj\ntrailer\n".
"<<\n/Root 1 0 R \n\n>>\n%%EOF\n";
return $data;
}
?>
last, this is the mod_process.php file that somehow marries the fdf to the pdf and enables an onscreen rendering of the pdf file. It seems to work on one site, but not at the other.
i am trying to figure out
1) how to make the fdf file connect to the pdf file so i can have 100% consistency no matter where the files are hosted
or
2) how to tweak the code so when i click the results link i always get the pdf fil
Code: Select all
<?php
require_once 'createFDF.php';
$pdf_file='http://www.americanlaw1.com/apdf/v12.pdf';
// allow for up to 25 different files to be created, based on the minute
$min=date('i') % 25;
$fdf_file=dirname(__FILE__).'/results/posted-'.$min.'.fdf';
if(isset($_POST['b_fname'])){
$_POST['b_cphone']=$_POST['b_cphone'];
// get the FDF file contents
$fdf=createFDF($pdf_file,$_POST);
// Create a file for later use
if($fp=fopen($fdf_file,'w')){
fwrite($fp,$fdf,strlen($fdf));
$CREATED=TRUE;
}else{
echo 'Unable to create file: '.$fdf_file.'<br><br>';
$CREATED=FALSE;
}
fclose($fp);
}
?>