Solved

Populate existing PDF with .xfdf form data stored in database using PHP/MySQL

Posted on 2010-09-01
25
2,896 Views
Last Modified: 2013-12-13
I have an HTML form that enters the values into a database. I use this PHP/MySQL code to retieve the data and create the .xfdf form data, then the .xfdf form data is entered into the database:
function createXFDF($file,$info,$enc='UTF-8'){
    $data='<?xml version="1.0" encoding="'.$enc.'"?>'."\n".
          '<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">'."\n".
            '<fields>'."\n";
    foreach($info as $field => $val){
          $data.='<field name="'.$field.'">'."\n";
        if(is_array($val)){
            foreach($val as $opt)
                $data.='<value>'.htmlentities($opt).'</value>'."\n";
        }else{
            $data.='<value>'.htmlentities($val).'</value>'."\n";
        }
        $data.='</field>'."\n";
    }
    $data.='</fields>'."\n".
          '<ids original="'.md5($file).'" modified="'.time().'" />'."\n".
          '<f href="'.$file.'" />'."\n".
          '</xfdf>'."\n";
    return $data;

   require_once('createxFDF.php');
   $id = $_GET['id'];
   $pdf_file='http://XXX.XXX.XXX.XXX/admin/application.pdf';
   include("login.php");
   login();
   $query = "select * from client where id=$id";
   $result = mysql_query($query);
   $row = mysql_fetch_array($result, MYSQL_ASSOC);

   $text_fields=array(
     $row['business_name'],
     $row['business_name2'],
     $row['business_address1'],
     $row['business_address2'],
     $row['legal_name'],
     $row['owner_first'],
     $row['owner_last'],
     $row['legal_phone'],
     $row['legal_fax'],
      );
        // get the xFDF file contents
        $xfdf=createxFDF($pdf_file,$text_fields);
        if (get_magic_quotes_gpc())
         {
          $xfdf = stripslashes($xfdf);
         }
       $xfdf=mysql_real_escape_string($xfdf);

      $query = "INSERT INTO applications SET apps='$xfdf', idnum='$id'";
      $result=mysql_query($query);
This works fine, using phpMyAdmin I can see the correct form data in the database.
Then when I try to retrieve the .xfdf form data from the database the existing PDF form (on the server) opens but the form data does not populate the fields in the form. Code:
   $idnum = $_GET['idnum'];
   include("login.php");
   login();
   $query = "SELECT * from applications where idnum=$idnum";
   $result = mysql_query($query);
   $row=mysql_fetch_array($result, MYSQL_ASSOC);
   $datafile = $row['apps'];
   header("Pragma: cache");
   header("Cache-Control: public");
   header("Content-Description: File Transfer");
   header("Content-type: application/vnd.adobe.xfdf");
   header("Content-Disposition: attachment; filename=application.xfdf");
   header("Expires: 0");
   echo $datafile;

I have based this code on code (which works fine) that takes the HTML field entries and directly populates the existing PDF form; but I need to have this performed from the .xfdf form data in the database not from the HTML form field $_POST values.
I have checked the field names in the PDF form are identical to the field names used to create the .xfdf form data file.
0
Comment
Question by:Lasados
  • 16
  • 9
25 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33586648
In the future, please post the code in the code snippet so we can see line numbers and unispace displays of the control structures, thanks.

Looking at these three lines of code...

   $query = "select * from client where id=$id";
   $result = mysql_query($query);
   $row = mysql_fetch_array($result, MYSQL_ASSOC);

... leads me to believe that you could use some foundation in how to use PHP and MySQL together.  You might benefit from this book.
http://www.sitepoint.com/books/phpmysql4/

The first of those three lines uses an external variable in a query.  DANGER: NEVER DO THAT!  Please see the man page here:
http://us3.php.net/manual/en/function.mysql-real-escape-string.php

In addition it looks like the script assumes there will be only one row from that query, but the query causes a table scan because it does not contain a LIMIT 1 clause.

The next line attempts to run a query, however the query might fail or return an empty results set.  Please see the "return values" on the man page here:
http://us3.php.net/manual/en/function.mysql-query.php

The third line attempts to use a PHP function with $result, and that may or may not be a valid results resource, but without testing you have no way of knowing what you might get back in $row.

Here is a code snippet that shows you how to do some of the basics in PHP and MySQL.  Note especially the use of var_dump() to visualize the data.  You might want to put some var-dump() statements into your code to see where the data-dependent issues arise (where data is missing or conditional code is executed or not executed).

HTH, ~Ray
<?php // RAY_mysql_example.php
error_reporting(E_ALL);


// IMPORTANT PAGES FROM THE MANUALS
// MAN PAGE: http://us2.php.net/manual/en/ref.mysql.php
// MAN PAGE: http://us2.php.net/manual/en/mysql.installation.php
// MAN PAGE: http://us.php.net/manual/en/function.mysql-error.php


// CONNECTION AND SELECTION VARIABLES FOR THE DATABASE
$db_host = "localhost"; // PROBABLY THIS IS OK
$db_name = "??";        // GET THESE FROM YOUR HOSTING COMPANY
$db_user = "??";
$db_word = "??";

// OPEN A CONNECTION TO THE DATA BASE SERVER
// MAN PAGE: http://us2.php.net/manual/en/function.mysql-connect.php
if (!$db_connection = mysql_connect("$db_host", "$db_user", "$db_word"))
{
   $errmsg = mysql_errno() . ' ' . mysql_error();
   echo "<br/>NO DB CONNECTION: ";
   echo "<br/> $errmsg <br/>";
}

// SELECT THE MYSQL DATA BASE
// MAN PAGE: http://us2.php.net/manual/en/function.mysql-select-db.php
if (!$db_sel = mysql_select_db($db_name, $db_connection))
{
   $errmsg = mysql_errno() . ' ' . mysql_error();
   echo "<br/>NO DB SELECTION: ";
   echo "<br/> $errmsg <br/>";
   die('NO DATA BASE');
}
// IF WE GOT THIS FAR WE CAN DO QUERIES




// ESCAPING A DATA FIELD FOR USE IN MYSQL QUERIES
// MAN PAGE: http://us2.php.net/manual/en/function.mysql-real-escape-string.php
$safe_username = mysql_real_escape_string($_POST["username"]);




// CREATING AND SENDING A SELECT QUERY AND TESTING THE RESULTS
// MAN PAGE:http://us2.php.net/manual/en/function.mysql-query.php
$sql = "SELECT id FROM my_table WHERE username='$safe_username'";
$res = mysql_query($sql);

// IF mysql_query() RETURNS FALSE, GET THE ERROR REASONS
// MAN PAGE: http://us.php.net/manual/en/function.mysql-error.php
if (!$res)
{
   $errmsg = mysql_errno() . ' ' . mysql_error();
   echo "<br/>QUERY FAIL: ";
   echo "<br/>$sql <br/>";
   die($errmsg);
}
// IF WE GET THIS FAR, THE QUERY SUCCEEDED AND WE HAVE A RESOURCE-ID IN $res SO WE CAN NOW USE $res IN OTHER MYSQL FUNCTIONS




// DETERMINE HOW MANY ROWS OF RESULTS WE GOT
// MAN PAGE: http://us2.php.net/manual/en/function.mysql-num-rows.php
$num = mysql_num_rows($res);
if (!$num)
{
   echo "<br/>QUERY FOUND NO DATA: ";
   echo "<br/>$sql <br/>";
}
else
{
   echo "<br/>QUERY FOUND $num ROWS OF DATA ";
   echo "<br/>$sql <br/>";
}




// ITERATE OVER THE RESULTS SET TO SHOW WHAT WE FOUND
// MAN PAGE: http://us2.php.net/manual/en/function.mysql-fetch-assoc.php
echo "<pre>\n"; // MAKE IT EASY TO READ
while ($row = mysql_fetch_assoc($res))
{
   var_dump($row); // MAN PAGE: http://us2.php.net/manual/en/function.var-dump.php
}

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33586662
Sidebar note, add error_reporting(E_ALL) to your code so you can catch any usage of undefined variables.  Sample on line 2 of my snippet.  And good luck!  Please post back here with your new code and any output from the var_dump() functions.
0
 

Author Comment

by:Lasados
ID: 33592033
Thanks for your reply.
Six years ago I did read parts of version 3 of the book you mention and completed a not very good Intermediate PHP/MySQL class from ed2go last year so I feel I have at least a "basic" foundation in how to use PHP and MySQL together.
That said, yes you are correct that I omitted error checking on my queries. I corrected these mistakes; but these mistakes are not the root of the problem.
I don't understand your comments about using an external variable (id=$id) in a query; probably because I did not supply enough code snippets. $id is obtained from a query of the database and assigned a value by $id = $row['id']; in the file which preceeds the code I supplied, so I don't think it is an external variable. It is a unique id value in the database.
What confuses me are the lines in your code:
$safe_username = mysql_real_escape_string($_POST["username"]);
$sql = "SELECT id FROM my_table WHERE username='$safe_username'";
Isn't $_POST["username"] an 'external' variable?
Maybe I'm confused about this, but let's move on to the actual problem with my programs.
I did not know about var_dump() so I used it in the attached file viewapps_vardump.php. (I am also attaching the original viewapps.php). The output (attached file viewapps_errormsg2.txt) is identical to the databse content for these variables (attached file viewapps_dbseid26data.txt which I copied from viewing the database contents via phpMyAdmin). I mentioned this in my posting that I could see the correct data via phpMyAdmin.
So I think the correct .xfdf data is written into the database; am I wrong?
And according to the var_dump() results the variables in viewapps.php have the correct content; the content is just not inserted into the existing .pdf.
I am also attaching a file (process_new.php) that I based my code on. It takes HTML form $_POST values directly, not from a database, and creates a functional .xfdf file which correctly populates the fields in the existing .pdf file. This is just for your reference so you can see that populating an existing .pdf file with .xfdf data is possible with PHP.
Why my code does not populate the existing .pdf file is the million dollar question. I hope you can figure it out.
viewapps-vardump.php
viewapps-errormsg2.txt
viewapps-dbseid26data.txt
viewapps.php
process-new.php
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33592199
Please see the code snippet.  This is why I think $id is an external data field.  It appears to have come from the URL GET string.  Of course it is possible that it comes from processing the included script named login.php, but that would beg the question of setting it in the first place.

$_POST is an external variable.  The mysql_real_escape_string() function is used to process it in my code sample.  Please read the man page here:
http://us3.php.net/manual/en/function.mysql-real-escape-string.php

Please use the code snippet to post code examples,  thanks! ~Ray
$id = $_GET['id'];
$pdf_file='http://XXX.XXX.XXX.XXX/admin/application.pdf';
include("login.php");
login();
$query = "select * from client where id=$id";

Open in new window

0
 

Author Comment

by:Lasados
ID: 33592358
Yes $id comes from a URL GET string. This is what was taught to me in the class. Are you saying I need to use $id = mysql_real_escape_string($id); after $id = $_GET['id']; ? Yes, I read the man page.
I don't think this is my main problem; just an aside.
Any thoughts on why my file viewapps.php does not work correctly?
I will use code snippet rather than file attachement in the future; I thought it would help to see the entire file.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33592539
Please see the code snippet.  After line 16, what is the contents of $datafile?  What do you want it to contain?
<?php
   error_reporting(E_ALL);
   $idnum = $_GET['idnum'];
   include("login.php");
   login();
   $query = "SELECT * from applications where idnum=$idnum";
   $result = mysql_query($query);
   if (!$result)
    {
     $errmsg = mysql_errno() . ' ' . mysql_error();
     echo "<br/>QUERY FAIL: ";
     echo "<br/>$query <br/>";
     die($errmsg);
    }
   $row=mysql_fetch_array($result, MYSQL_ASSOC);
   $datafile = $row['apps'];
   header("Pragma: cache");
   header("Cache-Control: public"); 
   header("Content-Description: File Transfer");
   header("Content-type: application/vnd.adobe.xfdf");
   header("Content-Disposition: attachment; filename=application.xfdf");
   header("Expires: 0");
   echo $datafile;
?>

Open in new window

0
 

Author Comment

by:Lasados
ID: 33592724
The output of line 16 was captured using the var_dump() you suggested and is the contents of the previously attached file viewapps_errormsg2.txt, but I will put it into the code snippet.
The data, which I believe to be correct .xfdf data, that was retrieved from the databse with the query is the contents of the previously attached file viewsapss_dbseid26data.txt, but I will put it into the code snippet. Thanks.
//contents of $datafile on line 16 captured by var_dump

array(2) {

  ["idnum"]=>

  string(2) "26"

  ["apps"]=>

  string(626) "<?xml version="1.0" encoding="UTF-8"?>

<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">

<fields>

<field name="0">

<value>Pro Software Design</value>

</field>

<field name="1">

<value>108 W Jefferson St</value>

</field>

<field name="2">

<value>Hudson</value>

</field>

<field name="3">

<value>Brad</value>

</field>

<field name="4">

<value>Hudson</value>

</field>

<field name="5">

<value>5555555555</value>

</field>

<field name="6">

<value>5555555555</value>

</field>

</fields>

<ids original="ad8443f3c2cc8d79d9101d5c8c771bfa" modified="1283459509" />

<f href="http://XX.XXX.XXX.XXX/admin/application.pdf" />

</xfdf>

"

}

string(626) "<?xml version="1.0" encoding="UTF-8"?>

<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">

<fields>

<field name="0">

<value>Pro Software Design</value>

</field>

<field name="1">

<value>108 W Jefferson St</value>

</field>

<field name="2">

<value>Hudson</value>

</field>

<field name="3">

<value>Brad</value>

</field>

<field name="4">

<value>Hudson</value>

</field>

<field name="5">

<value>5555555555</value>

</field>

<field name="6">

<value>5555555555</value>

</field>

</fields>

<ids original="ad8443f3c2cc8d79d9101d5c8c771bfa" modified="1283459509" />

<f href="http://XX.XX.XXX.XXX/admin/application.pdf" />

</xfdf>

"



//contents of database as viewed in phpMyAdmin

<?xml version="1.0" encoding="UTF-8"?>

<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">

<fields>

<field name="0">

<value>Pro Software Design</value>

</field>

<field name="1">

<value>108 W Jefferson St</value>

</field>

<field name="2">

<value>Hudson</value>

</field>

<field name="3">

<value>Brad</value>

</field>

<field name="4">

<value>Hudson</value>

</field>

<field name="5">

<value>5555555555</value>

</field>

<field name="6">

<value>5555555555</value>

</field>

</fields>

<ids original="ad8443f3c2cc8d79d9101d5c8c771bfa" modified="1283459509" />

<f href="http://XX.XXX.XXX.XXX/admin/application.pdf" />

</xfdf>

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33595433
Thanks for posting that.  It clears some of it up.  Looks like the data string we want is, in fact, available in $datafile = $row['apps'];

I copied that string and wrapped it with a download script.  When I ran this code, my browser opened Adobe Reader and Adobe Reader tried to access the URL in the "href" attribute of the"f" tag.  So it may be that these headers will work for you.  Have a look at the function in this script - try it, and post back with any questions.

Best regards, ~Ray

<?php // RAY_temp_Lasados.php

error_reporting(E_ALL);



// DATA FROM THE POST AT EE

$xml = <<<EOXML

<?xml version="1.0" encoding="UTF-8"?>

<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">

<fields>

<field name="0">

<value>Pro Software Design</value>

</field>

<field name="1">

<value>108 W Jefferson St</value>

</field>

<field name="2">

<value>Hudson</value>

</field>

<field name="3">

<value>Brad</value>

</field>

<field name="4">

<value>Hudson</value>

</field>

<field name="5">

<value>5555555555</value>

</field>

<field name="6">

<value>5555555555</value>

</field>

</fields>

<ids original="ad8443f3c2cc8d79d9101d5c8c771bfa" modified="1283459509" />

<f href="http://XX.XXX.XXX.XXX/admin/application.pdf" />

</xfdf>

EOXML;



// ACTIVATE THIS TO TEST FOR VALID XML

// $obj = SimpleXML_Load_String($xml);









/*

// OLD HEADERS FROM THE POST AT EE

   header("Pragma: cache");

   header("Cache-Control: public");

   header("Content-Description: File Transfer");

   header("Content-type: application/vnd.adobe.xfdf");

   header("Content-Disposition: attachment; filename=application.xfdf");

   header("Expires: 0");

*/









// FUNCTION TO FORCE XFDF FILE DOWNLOAD

function force_xfdf_download($filedata, $filename='application.xfdf')

{

    // GET A NAME FOR THE FILE

    $basename = basename($filename);



    if ($filedata)

    {

        // THESE HEADERS ARE USED ON ALL BROWSERS

        header("Content-Type: application/vnd.adobe.xfdf");

        header("Content-Disposition: attachment; filename=\"$basename\"");

        header("Content-length: ".(string)(strlen($filedata)));

        header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");

        header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");



        // THIS HEADER MUST BE OMITTED FOR IE 6+

        if (FALSE === strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE '))

        {

            header("Cache-Control: no-cache, must-revalidate");

        }



        // THIS IS THE LAST HEADER

        header("Pragma: no-cache");



        // FLUSH THE HEADERS TO THE BROWSER

        flush();



        // CAPTURE THE FILE IN THE OUTPUT BUFFERS - WILL BE FLUSHED AT SCRIPT END

        ob_start();

        echo $filedata;

    }

}



// RUN THE FUNCTION

force_xfdf_download($xml);

Open in new window

0
 

Author Comment

by:Lasados
ID: 33599165
Thanks for your help.
When I ran the code in the code snippet window (with the actual IP address rather than XXs) it does create the application.xfdf file to open or download/save. When I open the .xfdf file it launches Adobe Acrobat and a browser window with the application.pdf file displayed in the window. As before, a yellow bar prompts me that "Data from this site is blocked to avoid potential security risks. Click Options to receive this data if you trust this document". When I click the Options to trust this document the yellow bar goes away but the data does not populate the fields. This is the same behavior as previously obtained.
<?php // RAY_temp_Lasados.php

error_reporting(E_ALL);



// DATA FROM THE POST AT EE

$xml = <<<EOXML

<?xml version="1.0" encoding="UTF-8"?>

<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">

<fields>

<field name="0">

<value>Pro Software Design</value>

</field>

<field name="1">

<value>108 W Jefferson St</value>

</field>

<field name="2">

<value>Hudson</value>

</field>

<field name="3">

<value>Brad</value>

</field>

<field name="4">

<value>Hudson</value>

</field>

<field name="5">

<value>5555555555</value>

</field>

<field name="6">

<value>5555555555</value>

</field>

</fields>

<ids original="ad8443f3c2cc8d79d9101d5c8c771bfa" modified="1283459509" />

<f href="http://67.212.165.101/admin/application.pdf" />

</xfdf>

EOXML;



// ACTIVATE THIS TO TEST FOR VALID XML

// $obj = SimpleXML_Load_String($xml);









/*

// OLD HEADERS FROM THE POST AT EE

   header("Pragma: cache");

   header("Cache-Control: public");

   header("Content-Description: File Transfer");

   header("Content-type: application/vnd.adobe.xfdf");

   header("Content-Disposition: attachment; filename=application.xfdf");

   header("Expires: 0");

*/









// FUNCTION TO FORCE XFDF FILE DOWNLOAD

function force_xfdf_download($filedata, $filename='application.xfdf')

{

    // GET A NAME FOR THE FILE

    $basename = basename($filename);



    if ($filedata)

    {

        // THESE HEADERS ARE USED ON ALL BROWSERS

        header("Content-Type: application/vnd.adobe.xfdf");

        header("Content-Disposition: attachment; filename=\"$basename\"");

        header("Content-length: ".(string)(strlen($filedata)));

        header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), 



date("m"), date("d"), date("Y")))." GMT");

        header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");



        // THIS HEADER MUST BE OMITTED FOR IE 6+

        if (FALSE === strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE '))

        {

            header("Cache-Control: no-cache, must-revalidate");

        }



        // THIS IS THE LAST HEADER

        header("Pragma: no-cache");



        // FLUSH THE HEADERS TO THE BROWSER

        flush();



        // CAPTURE THE FILE IN THE OUTPUT BUFFERS - WILL BE FLUSHED AT SCRIPT END

        ob_start();

        echo $filedata;

    }

}



// RUN THE FUNCTION

force_xfdf_download($xml);

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33603729
"When I click the Options to trust this document the yellow bar goes away but the data does not populate the fields."

On my browser it said I could fill in data but I could not save the data.  Perhaps the issue is related to that?

The PHP parts of this appear to be solved -- I ran your most recent script post and it worked fine (so long as you do not mind a collection of warning messages).  Unfortunately this was the first time we had the ACTUAL URL available in this question, earlier versions were using a bogus URL like this:
http://XX.XXX.XXX.XXX/admin/application.pdf

So I was not able to see what was wrong until just now.

I think you might want to look for an Adobe Acrobat zone here at EE and try a new question there.

best regards, ~Ray
meramak.png
0
 

Author Comment

by:Lasados
ID: 33604104
Thanks for your reply and thanks for trying.
"On my browser it said I could fill in data but I could not save the data.  Perhaps the issue is related to that?"
No I don't think the issue is related to that since the same situation occurs using the orginal script (previously attached file process_new.php) which takes input directly from $_POST values (rather than from a database) and successfully populates the existing application.pdf file.

"The PHP parts of this appear to be solved -- I ran your most recent script post and it worked fine "
Sorry I disagree as the results (data not populating fields) are the same as my original script when I first submitted this question.

I will subit this question to the Adobe Acrobat zone but I doubt they are PHP/MySQL programmers.

Thanks for your help about my poor PHP/MySQL coding, I have learned something valuble from that. I will use your tips to try and become a better programmer.
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33604633
The results may be the same, but I do not think the issue is with the PHP part of things.  Adobe Reader (or Adobe Whatever) is issuing the error message. By the time we get to that point, the PHP part of things is long over.  So maybe we need to look at this from another angle.

Can you create a simple test case - a PDF that we can fill in with just one field on it, and that field pre-populated?  If you can show me how you have done that, maybe I can generalize it to show you how the PDF can be created with information from the data base.  It's often easier to do these things one step at a time.

Thanks, ~Ray
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

Author Comment

by:Lasados
ID: 33604814
Thanks much, you are indeed correct.
I have setup a one page test at http://67.212.165.101/apply_test.html . This is the original code which takes $_POST values, creates the .xfdf file and emails that file. It is what I tried to adapt to use the .xfdf file stored in a database rather than use the $_POST values.
In the first line you will need to enter the email address that you want to receive the .xfdf file at.(This is not part of the form to be used, the email would normally go to the office administrator but I have added this so you can do testing). All the content entered into the fields is NOT going to the database so I will not know your email address. The code in the snippet is the contents of process.php (the action in the form) which recieves the $_POST values, creates the .xfdf file and emails that file (normally hard coded to the office admin email address).
Thanks again! Lasados
process.php code:

<?php



    require_once('createXFDF.php');

    $mailto=$_POST['sendto'];

    $subject='Submitted Form Data';

    $from='louis@louiswebdesign.com';

    $pdf_file='http://67.212.165.101/admin/application.pdf';

    

    // set $redirect to '' to just output the fdf data to the browser, or give a URL for a

    // thank-you type of page

    $redirect='http://67.212.165.101/thankyou.html';

    

    // set $file_directory to '' to skip saving the file to server

    $file_directory='';

    

    $message='Open or Save the attachment in this message.';



    /**

     * fields accepted by this script

     */

    $text_fields=array(

    	'business_name',

    	'business_address1',

    	'business_city',

    	'business_state',

    	'business_zipcode',

    );

 

    if(isset($_POST['submit'])){

		unset($_POST['submit']); // don't need to process the submit button

    	

		foreach($_POST as $k=>$v){

			if(in_array($k,$text_fields)){

				// this field was an "accepted" field

				// verify contents (these are single lines, so no \r or \n)

				if(preg_match('`[\r\n]+`',$v)){

					$clean[$k]=''; // bad data - send empty

				}else{

					$clean[$k]=$v;

				}

			}else{

				// bad field option, we do nothing with this

				unset($_POST[$k]);

			}

		}

		

        // get the XFDF file contents

        $xfdf=createXFDF($pdf_file,$clean);



        // this seems to be the most popular request, so we will mail the xfdf to an account

        

        // this is the file attachment's name - you may want to customize this to fit your needs.

	    $fileattname = "appformdata.xfdf";

	    $fileatttype = "application/vnd.adobe.xfdf"; 

	    $data=chunk_split(base64_encode($xfdf));

	    $mime_boundary = '==Multipart_Boundary_x'.md5(time()).'x'; 

	    $headers = "From: $from\n".

	    	"MIME-Version: 1.0\n".

	        "Content-Type: multipart/mixed;\n".

	        " boundary=\"{$mime_boundary}\"";

	    $message = "This is a multi-part message in MIME format.\n\n".

	        "--{$mime_boundary}\n".

	        "Content-Type: text/plain; charset=\"iso-8859-1\"\n".

	        "Content-Transfer-Encoding: 7bit\n\n".

	        $message."\n\n".

	        "--{$mime_boundary}\n".

	        "Content-Type: {$fileatttype};\n".

	        " name=\"{$fileattname}\"\n".

	        "Content-Disposition: attachment;\n".

	        " filename=\"{$fileattname}\"\n".

	        "Content-Transfer-Encoding: base64\n\n".

	        $data."\n\n".

	        "--{$mime_boundary}--\n";

        if(!mail($mailto,$subject,$message,$headers)){

        	// mail failed!

        	mail(

        		$mailto,

        		'ERROR in '.__FILE__,

        		'Unable to send xfdf file via attachment. Data follows:'."\n----- Begin 



-----\n$xfdf\n----- End -----\n"

    		);

        }

        

		$file_name=time().'-'.$fileattname;

    	if(strlen($file_directory) && file_exists($file_directory) & is_writeable($file_directory)){

    		// if we have defined a writable directory on the server, write the results there as 



well

    		$target=$file_directory.'/'.$file_name;

    		if($fp=fopen($target,'w')){

    			fwrite($fp,$xfdf,strlen($xfdf));

    			fclose($fp);

    			

    			// mail notification of file creation

    			mail($mailto,'XFDF file saved to server',$target);

    		}else{

    			// can't open the file for writing...

    			mail($mailto,'XFDF file cannot be saved',"File cannot be written to server: 



$target\n");

    		}

    	}else if(strlen($file_directory)){

    		// can't use this directory - exists on server? writeable by web server process?

    		mail($mailto,'XFDF file directory cannot be used',"File cannot be written to server 



directory: $file_directory\n");

    	}

    	

    	if(strlen($redirect)){

    		// success - redirect if a redirect url is provided

    		header('Location: '.$redirect);

    		exit;

    	}else{

			// if no redirect, we want to just send the data to the browser

			

            // send the XFDF headers for the browser

            header('Content-type: application/vnd.adobe.xfdf');

            header('Content-Disposition: attachment; filename="'.$file_name.'"');

            echo $xfdf;

    	}

    }else{

    	die('This script is meant to be used in conjunction with the web forms on our website only.');

    }

?>

--------------------------------------------------

createxfdf function code:

<?php

/**

 * createXFDF

 * 

 * Takes values passed via associative array and generates XFDF file format

 * with that data for the pdf address supplied.

 * 

 * @param string $file The pdf file - url or file path accepted

 * @param array $info data to use in key/value pairs no more than 2 dimensions

 * @param string $enc default UTF-8, match server output: default_charset in php.ini

 * @return string The XFDF data for acrobat reader to use in the pdf form file

 */

function createXFDF($file,$info,$enc='UTF-8'){

    $data='<?xml version="1.0" encoding="'.$enc.'"?>'."\n".

    	'<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">'."\n".

		'<fields>'."\n";

    foreach($info as $field => $val){

    	$data.='<field name="'.$field.'">'."\n";

        if(is_array($val)){

            foreach($val as $opt)

                $data.='<value>'.htmlentities($opt).'</value>'."\n";

        }else{

            $data.='<value>'.htmlentities($val).'</value>'."\n";

        }

        $data.='</field>'."\n";

    }

    $data.='</fields>'."\n".

    	'<ids original="'.md5($file).'" modified="'.time().'" />'."\n".

    	'<f href="'.$file.'" />'."\n".

    	'</xfdf>'."\n";

    return $data;

}

?>

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33605059
OK, I will look at this again in the morning.  My email address is Ray.Paseur at Gmail.com -- you can find it in my public profile here at EE.
http://www.experts-exchange.com/M_3774417.html

If you need to reach me by phone you can call me at 703.346.0600.

Best, ~Ray
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33606210
Please check your if statement on line 87 - are there enough ampersands?
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33606230
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33606323
This is the first of a few posts.  This is the form I used, stripped of all the non-moving parts.  You can see the information in the form -- it made its way into the PDF, which I will post in a few moments.  Conclusion - I have a test bed that works to go from form-to-XML-to-PDF, so now we can work on getting the information from the data base into the XML.

Best regards, ~Ray
<?php // RAY_temp_Lasados_form.php ?>
<pre>
<form action="http://www.LAPRBass.com/RAY_temp_Lasados.php" method="post">
EMAIL: <input name="sendto" />
BIZNS: <input name="business_name" />
BIZAD: <input name="business_address1" />
BIZCT: <input name="business_city" />
BIZST: <input name="business_state" />
BIZIP: <input name="business_zipcode" />
<!-- NAME REQUIRED BY LOGIC OF ACTION SCRIPT -->
<input type="submit" name="submit" value="Go" />
</form>

Open in new window

Lasados-form-image.png
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33606331
This code snippet is the action script that I used to process the form input.  The image shows the PDF with the fields filled in (compare to earlier posted form image).
<?php // RAY_temp_Lasados.php
error_reporting(E_ALL);

require_once('RAY_temp_Lasados_create_XFDF.php');
$mailto   = $_POST['sendto'];
$subject  = 'Submitted Form Data';
$from     = 'louis@louiswebdesign.com';
$pdf_file = 'http://67.212.165.101/admin/application.pdf';

// set $redirect to '' to just output the fdf data to the browser, or give a URL for a thank-you type of page
$redirect = 'http://67.212.165.101/thankyou.html';
$redirect = '';

// set $file_directory to '' to skip saving the file to server
$file_directory = '';

$message = 'Open or Save the attachment in this message.';

/**
 * fields accepted by this script
 */
$text_fields = array
( 'business_name'
, 'business_address1'
, 'business_city'
, 'business_state'
, 'business_zipcode'
)
;

// FILTER POST DATA INTO clean ARRAY
if(isset($_POST['submit']))
{
    $clean = array();
    foreach($_POST as $k => $v)
    {
        if(in_array($k, $text_fields))
        {
            // DISCARD FIELDS WITH NEWLINE OR EOL
            if(preg_match('`[\r\n]+`',$v))
            {
                $clean[$k] = '';
            }
            else
            {
                $clean[$k] = $v;
            }
        }
    }

    // get the XFDF file contents
    $xfdf = createXFDF($pdf_file, $clean);

    // this seems to be the most popular request, so we will mail the xfdf to an account

    // this is the file attachment's name - you may want to customize this to fit your needs.
    $fileattname = "appformdata.xfdf";
    $fileatttype = "application/vnd.adobe.xfdf";
    $data=chunk_split(base64_encode($xfdf));
    $mime_boundary = '==Multipart_Boundary_x'.md5(time()).'x';
    $headers = "From: $from\n".
        "MIME-Version: 1.0\n".
        "Content-Type: multipart/mixed;\n".
        " boundary=\"{$mime_boundary}\"";
    $message = "This is a multi-part message in MIME format.\n\n".
        "--{$mime_boundary}\n".
        "Content-Type: text/plain; charset=\"iso-8859-1\"\n".
        "Content-Transfer-Encoding: 7bit\n\n".
        $message."\n\n".
        "--{$mime_boundary}\n".
        "Content-Type: {$fileatttype};\n".
        " name=\"{$fileattname}\"\n".
        "Content-Disposition: attachment;\n".
        " filename=\"{$fileattname}\"\n".
        "Content-Transfer-Encoding: base64\n\n".
        $data."\n\n".
        "--{$mime_boundary}--\n";
    if(!mail($mailto,$subject,$message,$headers)){
        // mail failed!
        mail(
            $mailto,
            'ERROR in '.__FILE__,
            'Unable to send xfdf file via attachment. Data follows:'."\n----- Begin-----\n$xfdf\n----- End -----\n"
        );
    }

    $file_name = time() . '-' . $fileattname;
    if ( strlen($file_directory) && file_exists($file_directory) && is_writeable($file_directory) )
    {
        // if we have defined a writable directory on the server, write the results there as well
        $target = $file_directory . '/' . $file_name;
        if ($fp = fopen($target , 'w'))
        {
            fwrite($fp, $xfdf, strlen($xfdf));
            fclose($fp);

            // mail notification of file creation
            mail($mailto,'XFDF file saved to server',$target);
        }
        else
        {
            // can't open the file for writing...
            mail($mailto,'XFDF file cannot be saved',"File cannot be written to server: $target\n");
        }
    }
    elseif (strlen($file_directory))
    {
        // can't use this directory - exists on server? writeable by web server process?
        mail($mailto,'XFDF file directory cannot be used',"File cannot be written to server directory: $file_directory\n");
    }

    if(strlen($redirect))
    {
        // success - redirect if a redirect url is provided
        header('Location: '.$redirect);
        exit;
    }
    else
    {
        // if no redirect, we want to just send the data to the browser
        // send the XFDF headers for the browser
        header('Content-type: application/vnd.adobe.xfdf');
        header('Content-Disposition: attachment; filename="'.$file_name.'"');
        echo $xfdf;
    }
}
else
{
    die('This script is meant to be used in conjunction with the web forms on our website only.');
}

Open in new window

Lasados-PDF-image.png
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33606338
This code snippet contains the "XFDF" script used by the action script, above, to generate the XML string with the data for the PDF.  The image is the security warning issued by Acrobat when it tries to connect to your "Meramak" web site.
<?php // RAY_temp_Lasados_create_XFDF.php
error_reporting(E_ALL);
/**
 * createXFDF
 *
 * Takes values passed via associative array and generates XFDF file format
 * with that data for the pdf address supplied.
 *
 * @param string $file The pdf file - url or file path accepted
 * @param array $info data to use in key/value pairs no more than 2 dimensions
 * @param string $enc default UTF-8, match server output: default_charset in php.ini
 * @return string The XFDF data for acrobat reader to use in the pdf form file
 */
function createXFDF($file, $info, $enc='UTF-8')
{
    // INITIALIZE THE XML STRING
    $data  = '<?xml version="1.0" encoding="' . $enc . '"?>' . PHP_EOL
    . '<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">' . PHP_EOL
    . '<fields>' . PHP_EOL
    ;

    // PROCESS THE ASSOCIATIVE ARRAY
    foreach ($info as $field => $val)
    {
        // ADD AN OPENING field TAG TO THE XML STRING
        $data .= '<field name="'
        . $field
        . '">'
        . PHP_EOL
        ;

        // IF THERE IS ONE AND ONLY ONE LEVEL OF SUB-ARRAY ADD SEVERAL VALUE TAGS
        if(is_array($val))
        {
            foreach($val as $opt)
            {
                $data .= '<value>'
                . htmlentities($opt)
                . '</value>'
                . PHP_EOL;
            }
        }

        // IF THERE IS NO SUB-ARRAY ADD A SINGLE VALUE TAG
        else
        {
            $data .= '<value>'
            . htmlentities($val)
            . '</value>'
            . PHP_EOL
            ;
        }

        // ADD A CLOSING field TAG TO THE XML STRING
        $data .= '</field>' . PHP_EOL
          ;
    }

    // CLOSE OUT THE XML STRING
    $data .= '</fields>'
    . PHP_EOL
    . '<ids original="'
    . md5($file)
    . '" modified="'
    . time()
    . '" />'
    . PHP_EOL
    . '<f href="'
    . $file
    . '" />'
    . PHP_EOL
    . '</xfdf>'
    . PHP_EOL
    ;

    // ACTIVATE THIS TO SEE THE GENERATED XML
    // echo "<pre>" . htmlentities($data);
    return $data;
}

Open in new window

Lasados-security-image.png
0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33606347
Now, going back to your original post I see a code set that says this (see snippet).  It would be useful to see the array that came out of the data base, using var_dump().  In the next snippet I will show you why I think this matters.
$idnum = $_GET['idnum'];
   include("login.php");
   login();
   $query = "SELECT * from applications where idnum=$idnum";
   $result = mysql_query($query);
   $row=mysql_fetch_array($result, MYSQL_ASSOC);
   $datafile = $row['apps'];
   header("Pragma: cache");
   header("Cache-Control: public");
   header("Content-Description: File Transfer");
   header("Content-type: application/vnd.adobe.xfdf");
   header("Content-Disposition: attachment; filename=application.xfdf");
   header("Expires: 0");
   echo $datafile;

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33606365
Here in the code snippet is the XML we find in dbseid26data.txt.

As you can see the field names are numbers only.  In my successful test, the XML had field names that came from the POST keys.  I suspect that the data base may have these numbers in the field names, instead of the name strings, like these...

EMAIL: <input name="sendto" />
BIZNS: <input name="business_name" />
BIZAD: <input name="business_address1" />
BIZCT: <input name="business_city" />
BIZST: <input name="business_state" />
BIZIP: <input name="business_zipcode" />

So instead of '<field name="0">' you might need to have '<field name="business_name">', etc...
<?xml version="1.0" encoding="UTF-8"?>
<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">
<fields>
<field name="0">
<value>Pro Software Design</value>
</field>
<field name="1">
<value>108 W Jefferson St</value>
</field>
<field name="2">
<value>Hudson</value>
</field>
<field name="3">
<value>Brad</value>
</field>
<field name="4">
<value>Hudson</value>
</field>
<field name="5">
<value>3175142099</value>
</field>
<field name="6">
<value>3175142099</value>
</field>
</fields>
<ids original="ad8443f3c2cc8d79d9101d5c8c771bfa" modified="1283459509" />
<f href="http://67.212.165.101/admin/application.pdf" />
</xfdf>

Open in new window

0
 

Accepted Solution

by:
Lasados earned 0 total points
ID: 33608101
Thanks much. I was already able to make the program work with $_POST values but thank you for your better code. Since the form is a 3 page form I had to write all the $_POST values to $_SESSION variables, then use those. But it works fine.
Yes there was an ampersand missing.
Concerning the validation errors, a previous web designer created all the webpages. I was only hired to complete the site he abandoned; that is I am only working on the back end to generate the final PDF file. Sorry, but I don't take the blame for his coding. If I have time I will fix his mistakes. Besides, this is off topic.
You are correct, the .xfdf file incorrectly had numbers for field names rather than the correct field names associated with the field names assigned in the application.pdf file. I was able to fix the problem with the .xfdf file data creation by looking at the code using $_POST values and then changing the file (applicant.php - see code snippet) that uses $row database values to create the .xfdf. I had the array wrong (it should be the PDF field names) and then added a foreach loop from the original file that creates the field names correctly and the values associated with them correctly.
Now it creates the .xfdf file with field names not as numbers but as the proper field names coded in the application.pdf file. Only problem now is that with  error_reporting(E_ALL); at the beginning of the viewapps.php file it dumps error messages into the beginning of the .xfdf file. If I remove those error messages then open the .xfdf file it opens the PDF file and populates the data correctly!!! We are so close to having this work I am excited!
I'm also including the contents of the new .xfdf file with the errors at the top and the file viewapps.php that generates the error messages.
old applicant.php code that was wrong:

<?php

   error_reporting(E_ALL);

   require_once('createxFDF.php');

   $id = $_GET['id'];

   $pdf_file='http://67.212.165.101/admin/application.pdf';

   include("login.php");

   login();

   $query = "select * from client where id=$id";

   $result = mysql_query($query);

   if (!$result)

    {

     $errmsg = mysql_errno() . ' ' . mysql_error();

     echo "<br/>QUERY FAIL: ";

     echo "<br/>$sql <br/>";

     die($errmsg);

    }

   $row = mysql_fetch_array($result, MYSQL_ASSOC);



   $text_fields=array(

     $row['business_name'],

     $row['business_address1'],

     $row['legal_name'],

     $row['owner_first'],

     $row['owner_last'],

     $row['legal_phone'],

     $row['legal_fax'],

	);

    	

	

        // get the xFDF file contents

        $xfdf=createxFDF($pdf_file,$text_fields);

        if (get_magic_quotes_gpc())

         {

          $xfdf = stripslashes($xfdf);

         }

	$xfdf=mysql_real_escape_string($xfdf);



      $query2 = "INSERT INTO applications SET apps='$xfdf', idnum='$id'";

      $result2=mysql_query($query2);



      if ($result2)

      {

         header("Location: admin.php?p=applications2&idnum=$id");

      }

      else

      {

         echo "<h2>Sorry, I could not process your form at this time</h2>\n";

      }

---------------------------------------

new code of applicant.php that correctly assigns field names and field values:

<?php

   error_reporting(E_ALL);

   require_once('createxFDF.php');

   $id = $_GET['id'];

   $pdf_file='http://67.212.165.101/admin/application.pdf';

   include("login.php");

   login();

   $query = "select * from client where id=$id";

   $result = mysql_query($query);

   if (!$result)

    {

     $errmsg = mysql_errno() . ' ' . mysql_error();

     echo "<br/>QUERY FAIL: ";

     echo "<br/>$sql <br/>";

     die($errmsg);

    }

   $row = mysql_fetch_array($result, MYSQL_ASSOC);



   $text_fields=array(

    	'business_name',

    	'business_address1',

    	'business_city',

    	'business_state',

    	'business_zipcode',

	);

  

		foreach($row as $k=>$v){

			if(in_array($k,$text_fields)){

				// this field was an "accepted" field

				// verify contents (these are single lines, so no \r or \n)

				if(preg_match('`[\r\n]+`',$v)){

					$clean[$k]=''; // bad data - send empty

				}else{

					$clean[$k]=$v;

				}

			}



		}     	

	

        // get the xFDF file contents

        $xfdf=createxFDF($pdf_file,$clean);

        if (get_magic_quotes_gpc())

         {

          $xfdf = stripslashes($xfdf);

         }

	$xfdf=mysql_real_escape_string($xfdf);



      $query2 = "INSERT INTO applications SET apps='$xfdf', idnum='$id'";

      $result2=mysql_query($query2);



      if ($result2)

      {

         header("Location: admin.php?p=applications2&idnum=$id");

      }

      else

      {

         echo "<h2>Sorry, I could not process your form at this time</h2>\n";

      }

-----------------------------------------

contents of .xfdf file created with error messages at top:

<br />

<b>Notice</b>:  Undefined variable:  filedata in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>33</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php:33) in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>33</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php:33) in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>34</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php:33) in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>35</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php:33) in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>44</b><br />

<<<EOXML

<?xml version="1.0" encoding="UTF-8"?>

<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">

<fields>

<field name="business_name">

<value>New Test</value>

</field>

<field name="business_address1">

<value>494 North Ave.</value>

</field>

<field name="business_city">

<value>San Jose</value>

</field>

<field name="business_state">

<value>CA</value>

</field>

<field name="business_zipcode">

<value>11111</value>

</field>

</fields>

<ids original="ad8443f3c2cc8d79d9101d5c8c771bfa" modified="1283713125" />

<f href="http://67.212.165.101/admin/application.pdf" />

</xfdf>

EOXML;

----------------------------------------

file viewapps.php that generates error messages:

<?php

   error_reporting(E_ALL);

   $idnum = $_GET['idnum'];

   include("login.php");

   login();

   $query = "SELECT apps from applications where idnum=$idnum";

   $result = mysql_query($query);

   if (!$result)

    {

     $errmsg = mysql_errno() . ' ' . mysql_error();

     echo "<br/>QUERY FAIL: ";

     echo "<br/>$query <br/>";

     die($errmsg);

    }

   $row=mysql_fetch_array($result, MYSQL_ASSOC);

   $datafile = $row['apps'];

   $xml = $datafile;



// ACTIVATE THIS TO TEST FOR VALID XML

// $obj = SimpleXML_Load_String($xml);



// FUNCTION TO FORCE XFDF FILE DOWNLOAD

function force_xfdf_download($datafile, $filename='application.xfdf')

{

    // GET A NAME FOR THE FILE

    $basename = basename($filename);



    if ($datafile)

    {

        // THESE HEADERS ARE USED ON ALL BROWSERS

        header("Content-Type: application/vnd.adobe.xfdf");

        header("Content-Disposition: attachment; filename=\"$basename\"");

        header("Content-length: ".(string)(strlen($filedata)));

        header("Expires: ".gmdate("D, d M Y H:i:s", mktime(date("H")+2, date("i"), date("s"), date("m"), date("d"), date("Y")))." GMT");

        header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");



        // THIS HEADER MUST BE OMITTED FOR IE 6+

        if (FALSE === strpos($_SERVER["HTTP_USER_AGENT"], 'MSIE '))

        {

            header("Cache-Control: no-cache, must-revalidate");

        }



        // THIS IS THE LAST HEADER

        header("Pragma: no-cache");



        // FLUSH THE HEADERS TO THE BROWSER

        flush();



        // CAPTURE THE FILE IN THE OUTPUT BUFFERS - WILL BE FLUSHED AT SCRIPT END

        ob_start();

        echo $datafile;

    }

}



// RUN THE FUNCTION

force_xfdf_download($xml);



?>

Open in new window

0
 

Author Comment

by:Lasados
ID: 33608136
Correction, the .xfdf data file does not have <<<EOXML and EOXML;
Code snippet has correct content.

<br />

<b>Notice</b>:  Undefined variable:  filedata in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>33</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php:33) in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>33</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php:33) in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>34</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php:33) in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>35</b><br />

<br />

<b>Warning</b>:  Cannot modify header information - headers already sent by (output started at C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php:33) in <b>C:\Inetpub\vhosts\meramak.com\httpdocs\admin\viewapps.php</b> on line <b>44</b><br />

<?xml version="1.0" encoding="UTF-8"?>

<xfdf xmlns="http://ns.adobe.com/xfdf/" xml:space="preserve">

<fields>

<field name="business_name">

<value>New Test</value>

</field>

<field name="business_address1">

<value>494 North Ave.</value>

</field>

<field name="business_city">

<value>San Jose</value>

</field>

<field name="business_state">

<value>CA</value>

</field>

<field name="business_zipcode">

<value>11111</value>

</field>

</fields>

<ids original="ad8443f3c2cc8d79d9101d5c8c771bfa" modified="1283727612" />

<f href="http://67.212.165.101/admin/application.pdf" />

</xfdf>

Open in new window

0
 
LVL 108

Expert Comment

by:Ray Paseur
ID: 33608163
If you have error_reporting(E_ALL) and you get notices or similar messages you face two choices.

1. Correct the error conditions that result in the messages (this is what you should do if you are accepting pay for your work).
2. Suppress the messages and accept the fact that errors may corrupt your data some day -- and you will not know until it is too late.

It sounds like we have solved the important issues.  Good luck with your project, ~Ray
0
 

Author Comment

by:Lasados
ID: 33619267
Well gee thanks?
I fixed the error messages.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Encode a password 2 39
Wordpress Query 1 35
session dropped in IE 10 22
sql sentence 2 13
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now