• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2451
  • Last Modified:

fpdf to generate pdf as email attachment - getting random, blank submissions

hi - i have a client that's receiving random, blank fpdf form submissions - so the pdf is blank- i've tested the form myself and added recapcha  - form submits fine when i do it and recaptcha is working - any ideas how this might be happening?
<?php error_reporting(7); if ($_GET['hdwtest']=='captchainstalled') { echo 'Captcha verification code installed.'; exit; } if (count($_POST) > 0 || count($_GET) > 4) { @session_start(); foreach ($_GET as $item => $value)@setcookie ('hdw_'.$item, $value, 0, '/');foreach ($_POST as $item => $value)@setcookie ('hdw_'.$item, $value, 0, '/');foreach ($_COOKIE as $item => $value)	  if (substr($item,0,4) == 'hdw_' && $_GET[substr($item,4)] == '' && $_POST[substr($item,4)] == '')@setcookie ($item, '', 0, '/'); if ((empty($_POST['hdcaptcha']) || $_POST['hdcaptcha'] == '' || strtolower($_POST['hdcaptcha']) != strtolower($_SESSION['rand_code'])) && (empty($_GET['hdcaptcha']) || $_GET['hdcaptcha'] == '' || strtolower($_GET['hdcaptcha']) != strtolower($_SESSION['rand_code']))) {if ($_POST['hdwfail'] != '')header('Location: '.$_POST['hdwfail']);else	header('Location: '.$_GET['hdwfail']);exit;} foreach ($_COOKIE as $item => $value) if (substr($item,0,4) == 'hdw_')@setcookie ($item, '', 0, '/'); } reset($_POST);reset($_GET); ?>
<?php
require('fpdf/fpdf.php');
$applicant = ($_POST['Patient_Name']);
 
class PDF extends FPDF
{
var $B;
var $I;
var $U;
var $HREF;
 
function PDF($orientation='P',$unit='mm',$format='A4')
{
    //Call parent constructor
    $this->FPDF($orientation,$unit,$format);
    //Initialization
    $this->B=0;
    $this->I=0;
    $this->U=0;
    $this->HREF='';
}
 
function WriteHTML($html)
{
    //HTML parser
    $html=str_replace("\n",' ',$html);
    $a=preg_split('/<(.*)>/U',$html,-1,PREG_SPLIT_DELIM_CAPTURE);
    foreach($a as $i=>$e)
    {
        if($i%2==0)
        {
            //Text
            if($this->HREF)
                $this->PutLink($this->HREF,$e);
            else
                $this->Write(5,$e);
        }
        else
        {
            //Tag
            if($e{0}=='/')
                $this->CloseTag(strtoupper(substr($e,1)));
            else
            {
                //Extract attributes
                $a2=explode(' ',$e);
                $tag=strtoupper(array_shift($a2));
                $attr=array();
                foreach($a2 as $v)
                    if(ereg('^([^=]*)=["\']?([^"\']*)["\']?$',$v,$a3))
                        $attr[strtoupper($a3[1])]=$a3[2];
                $this->OpenTag($tag,$attr);
            }
        }
    }
}
 
function OpenTag($tag,$attr)
{
    //Opening tag
    if($tag=='B' or $tag=='I' or $tag=='U')
        $this->SetStyle($tag,true);
    if($tag=='A')
        $this->HREF=$attr['HREF'];
    if($tag=='BR')
        $this->Ln(5);
}
 
function CloseTag($tag)
{
    //Closing tag
    if($tag=='B' or $tag=='I' or $tag=='U')
        $this->SetStyle($tag,false);
    if($tag=='A')
        $this->HREF='';
}
 
function SetStyle($tag,$enable)
{
    //Modify style and select corresponding font
    $this->$tag+=($enable ? 1 : -1);
    $style='';
    foreach(array('B','I','U') as $s)
        if($this->$s>0)
            $style.=$s;
    $this->SetFont('',$style);
}
 
function PutLink($URL,$txt)
{
    //Put a hyperlink
    $this->SetTextColor(0,0,255);
    $this->SetStyle('U',true);
    $this->Write(5,$txt,$URL);
    $this->SetStyle('U',false);
    $this->SetTextColor(0);
}
 
function Header()
{
    //Select Arial bold 12
    $this->SetFont('Arial','B',11);
	$this->SetTextColor(0,0,0);
    
    //Framed title
    $this->Cell(180,10,'Cornerstone Surgery Center',0,1,'C');
	$this->Cell(180,10,'PATIENT SURVEY',0,1,'C');
	//Line break
    $this->Ln(2);
	$this->SetTextColor(0,0,0);
$this->SetFont('Arial','B',8);
$this->Cell(90,5,'Patient Name:',0,0,'R');
$this->SetFont('Arial','I',8);
$this->Cell(90,5,$_POST['Patient_Name'],0,1,'L');
$this->SetFont('Arial','B',8);
$this->Cell(90,5,'Procedure Date:',0,0,'R');
$this->SetFont('Arial','I',8);
$this->Cell(90,5,$_POST['procedure_date'],0,1,'L');
$this->Ln(5);
 
	
}
function Footer()
{
    //Go to 1.5 cm from bottom
    $this->SetY(-15);
    //Select Arial italic 8
    $this->SetFont('Arial','I',8);
    //Print centered page number
    //Page number
	$this->SetTextColor(0,0,0);
    $this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
 
$html='You can now easily print text mixing different
styles : <B>bold</B>, <I>italic</I>, <U>underlined</U>, or
<B><I><U>all at once</U></I></B>!<BR>You can also insert links
on text, such as <A HREF="http://www.fpdf.org">www.fpdf.org</A>,
or on an image: click on the logo.';
$authorize='I AUTHORIZE the doctor referenced above and such assistants as he may designate, to administer and conduct the exercise stress test. This test is designed to measure my fitness for work and/or sport, to determine the presence or absence of clinically significant heart disease, and/or evaluate the effectiveness of my current  therapy.<br><br>I understand that I will walk on a motor driven treadmill during the test or administered (i.e. Adenosine) medication through an intravenous line during the test. My electrocardiogram will be monitored and my blood pressure will  be measured. Exercise will be progressively increased until I attain a predetermined end point corresponding to moderate exercise stress, or become distressed in any way, or develop any abnormal response the physician considers significant, whichever of the above occurs first. <br><br>Every effort will be made to conduct the test in such a way as to minimize discomfort and risk. However, I understand that just as with other types of diagnostic tests, there are potential risks (approximately 2 to 3 per 10,000) associated with an exercise test. These include episodes of transient light-headedness, fainting, disorders of heart beat and very rarely the possibility of heart attack. I further understand that the laboratory is properly equipped for such situations and that its professional personnel are trained to administer any emergency care necessary. I voluntarily accept the risks associated with the above procedure. ';
			  
$agree='Please check with your pharmacy after 24 hours to allow us the needed time to process your prescription refill request. Click on the Submit button below to process your request.';			  
 
$pdf=new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
 
//Personal Info
$pdf->SetFont('Arial','B',9);
$pdf->SetTextColor(220,50,50);
$pdf->Cell(180,8,'Background Questions',1,1,'C');
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->Cell(40,5,'Patient Sex:',1,0,'R');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(50,5,$_POST['Patient_Sex'],1,0,'L');
$pdf->SetFont('Arial','B',8);
$pdf->Cell(40,5,'Patient Age:',1,0,'R');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(50,5,$_POST['Patient_Age'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->Cell(40,5,'Physician:',1,0,'R');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(140,5,$_POST['Physician'],1,1,'L');
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Was this your first visit to our Ambulatory Surgery Center?',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['First_Visit'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->Cell(40,5,'Patient Name:',1,0,'R');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(50,5,$_POST['Patient_Name'],1,0,'L');
$pdf->SetFont('Arial','B',8);
$pdf->Cell(40,5,'Telephone Number:',1,0,'R');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(50,5,$_POST['Patient_Telephone'],1,1,'L');
 
 
//Registration
//HEADING
$pdf->SetTextColor(220,50,50);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(180,8,'A. Registration',1,1,'C');
 
//QUESTIONS
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Professional and courteous service of registration',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['1_Registration'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Satisfactory answers to financial and insurance questions',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['2_Registration'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Speed and efficiency of registration',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['3_Registration'],1,1,'L');
 
//Facility
//HEADING
$pdf->SetTextColor(220,50,50);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(180,8,'B. Facility',1,1,'C');
 
//QUESTIONS
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Comfort of the registration waiting area ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['1_Facility'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Comfort of your seat or resting area in the Center ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['2_Facility'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Attractiveness of the surgery center',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['3_Facility'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Cleanliness of the surgery center ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['4_Facility'],1,1,'L');
 
//Nursing
//HEADING
$pdf->SetTextColor(220,50,50);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(180,8,'C. Nursing',1,1,'C');
 
//QUESTIONS
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Waiting time before your surgery or procedure began',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['1_Nursing'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Explanation the physician gave you about the surgery or procedure',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['2_Nursing'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Professional and courteous service of the nurses ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['3_Nursing'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Skill of the nurse starting IV ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['4_Nursing'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Nurses explaining procedures  ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['5_Nursing'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Nurses concern for your comfort ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['6_Nursing'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Nurses courtesy towards family who accompanied you (if applicable)',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['7_Nursing'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Instructions nurses gave about caring for yourself at home ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['8_Nursing'],1,1,'L');
 
//PersonalIssues
//HEADING
$pdf->SetTextColor(220,50,50);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(180,8,'D. Personal Issues',1,1,'C');
 
//QUESTIONS
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Information provided about delays (if you experienced delays) ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['1_PersonalIssues'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Our concern for your privacy  ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['2_PersonalIssues'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Degree to which your pain was controlled  ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['3_PersonalIssues'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Response to concerns/complaints made during your visit ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['4_PersonalIssues'],1,1,'L');
 
//OverallAssessment
//HEADING
$pdf->SetTextColor(220,50,50);
$pdf->SetFont('Arial','B',9);
$pdf->Cell(180,8,'E. Overall Assessment',1,1,'C');
 
//QUESTIONS
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Overall rating of care received during your visit',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['1_OverallAssessment'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Degree to which staff worked together to care for you',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['2_OverallAssessment'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Likelihood of your recommending our Ambulatory Surgery Center to others ',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->Cell(180,5,$_POST['3_OverallAssessment'],1,1,'L');
 
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','B',8);
$pdf->MultiCell(180,5,'Comments (describe good or bad experiences):',1,1,'L');
$pdf->SetFont('Arial','I',8);
$pdf->MultiCell(180,5,$_POST['4_OverallAssessment'],1,1,'L');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
$pdfcontent = $pdf->Output("helloworld.pdf", "S");
 
################################################################################
################################################################################
//output to e-mail 
//output to e-mail 
 
 
require_once('fpdf/Mail.php');
require_once('fpdf/Mail_Mime/mime.php');
 
// email address of the recipient
$to = "meg@cornerstonesurgerycenter.com";
 
 
 
 
// email address of the sender
$from = "donotreply@cornerstonesurgerycenter.com";
 
// subject of the email
$subject = 'Patient Survey Submission from:  '.$applicant;
 
// email header format complies the PEAR's Mail class
// this header includes sender's email and subject
$headers = array('From' => $from,
'Subject' => $subject);
 
// We will send this email as HTML format
// which is well presented and nicer than plain text
// using the heredoc syntax
// REMEMBER: there should not be any space after PDFMAIL keyword
$htmlMessage = <<<PDFMAIL
<html>
<body bgcolor="#ffffff">
<p align="left">
You have received this automated
mailing from the Cornerstone Surgery Center.
Please do not respond to this email. This message
contains an attached Patient Survey.
</p>
</body>
</html>
PDFMAIL;
 
// create a new instance of the Mail_Mime class
$mime = new Mail_Mime();
 
// set HTML content
$mime->setHtmlBody($htmlMessage);
 
// IMPORTANT: add pdf content as attachment
$mime->addAttachment($pdfcontent, 'application/pdf', 'Cornerstone_Patient_Survey.pdf', false, 'base64');
 
// build email message and save it in $body
$body = $mime->get();
 
// build header
$hdrs = $mime->headers($headers);
 
// create Mail instance that will be used to send email later
$mail = &Mail::factory('mail');
 
// Sending the email, according to the address in $to,
// the email headers in $hdrs,
// and the message body in $body.
$mail->send($to, $hdrs, $body);
 
header ('Location: http://cornerstonesurgerycenter.com/survey_thanks.php');
 
?>

Open in new window

0
phillystyle123
Asked:
phillystyle123
  • 7
  • 6
1 Solution
 
Ray PaseurCommented:
Wow, 450 lines that need debugging!  What have you tried to debug this, so far?

Let's start with the basics.  Put error_reporting(E_ALL) into the script and break up the statements so we can see what the code is doing.  I tried to split up the first line of it and I couldn't even figure it out!  It's so easy to write code with clear indentations and comments, and so much easier to debug when you can look at the code and see the comments and the control structures!

You're aware that the $_COOKIE array is not available to the script that sets the cookie, right?

You're aware that you almost certainly want die() commands after header("Location: ") commands?

Is the PDF getting written into a file on the server?  Is it intact there on every occasion?  What else can you tell us about the symptoms?

Thanks, ~Ray
<?php // THIS IS WRONG, BECAUSE THE CONTROL STRUCTURES ARE OBSCURED BY THE RUN-ON LINES AND LACK OF CURLY BRACES - BEST TO REWRITE THIS SO ITS INTENT IS CLEAR
error_reporting(e_all); 
if ($_GET['hdwtest']=='captchainstalled') 
{ 
   echo 'Captcha verification code installed.'; 
   exit; 
} 
 
if (count($_POST) > 0 || count($_GET) > 4) 
{ 
   session_start(); 
   foreach ($_GET as $item => $value)
   {
      if (!setcookie ('hdw_'.$item, $value, 0, '/')) die("COOKIE FAILED $item value");
   }
   
   foreach ($_POST as $item => $value)
   {
      if (!setcookie ('hdw_'.$item, $value, 0, '/')) die("COOKIE FAILED $item $value");
   }
   
   foreach ($_COOKIE as $item => $value)
   {
      if (substr($item,0,4) == 'hdw_' && $_GET[substr($item,4)] == '' && $_POST[substr($item,4)] == '')
   }
 
   if (!setcookie ($item, '', 0, '/')) die("COOKIE FAILED $item $value");
 
   if ( ( empty($_POST['hdcaptcha']) 
        || $_POST['hdcaptcha'] == '' 
        || strtolower($_POST['hdcaptcha']) 
        != strtolower($_SESSION['rand_code']) ) 
        && ( empty($_GET['hdcaptcha']) 
        || $_GET['hdcaptcha'] == '' 
        || strtolower($_GET['hdcaptcha']) 
        != strtolower($_SESSION['rand_code']) )
      ) 
   {
      if ($_POST['hdwfail'] != '')
      {
         header('Location: '.$_POST['hdwfail']);
         exit;
      }else{
         header('Location: '.$_GET['hdwfail']);
         exit;
      } 
      foreach ($_COOKIE as $item => $value)
      {
         if (substr($item,0,4) == 'hdw_')
         {
            setcookie ($item, '', 0, '/'); 
         } 
         reset($_POST);
         reset($_GET); 
         ?>

Open in new window

0
 
phillystyle123Author Commented:
Hi Ray,

The issue was occuring prior to adding the recaptcha code. Unfortuantely I don't have the time comment this code and organize it more than it already is.  The entire recaptcha part at the top (see code snippet) is a dw extension - but, again, this issue was happening prior to my adding it and it's still happening.

This phenomenon has occurred with other instances of this code. Basically, without a user submitting the form, the email with pdf attachment that is supposed to be generated only when the form is submitted gets sent to the recipient - but the pdf is blank.
0
 
Ray PaseurCommented:
Well, if you don't have time to comment it, I certainly don't!  But I have never had a failure of any sort with FPDF, so my guess is that there is something external that is a factor.

Is the PDF getting written into a file on the server?  Is it intact there on every occasion?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
phillystyle123Author Commented:
My point is that all except for recaptcha is already commented AND i had this issue before I added recaptcha so, I'm pretty sure the 2 are unrelated.

Is the PDF getting written into a file on the server?

How do I check?


Is it intact there on every occasion?

I don't know what this means.
0
 
Ray PaseurCommented:
"Is the PDF getting written into a file on the server?  How do I check?"

What do you expect FPDF to do with the output of its processing?  When I have used FPDF I wrote the generated PDF file into a directory on the server, so I could look at it.  That way I could tell whether it was creating what I wanted and expected.

What I'm aiming for here is to try to isolate the error, which may be either code or data dependent.  I saw in some of the code above (for example) that there was a header("Location") command that was NOT followed by a die() command.  That means that after issuing the header to cause the redirect, your code keeps right on running until the client's browser redirects to the new page.  In other words, the results of doing something like that are unpredictable.  I'm hoping to lead you in the direction of running only predictable code so we can get a repeatable pattern of success or failure.  Then we can have some good chance to debug this.

Make sense?
0
 
phillystyle123Author Commented:
OK - I think I know what you mean -fpdf is creating a PDF that is sent as an email attachment - I'm not storing the PDF file anywhere on the server.

this is intriguing -

header ('Location: http://cornerstonesurgerycenter.com/survey_thanks.php');

should this be

header ('Location: http://cornerstonesurgerycenter.com/survey_thanks.php') or die(mysql_error());
0
 
Ray PaseurCommented:
Regarding this: "I'm not storing the PDF file anywhere on the server." - you might want to change the strategy so that you begin storing it on the server.  That way you have something to look at when you are trying to figure out what's wrong!  Otherwise, you have some invisible data, and you don't know anything more than you know now.  If we can see what FPDF is creating, it will be most helpful.

The suggested header command does not make sense to me.

header ('Location: http://cornerstonesurgerycenter.com/survey_thanks.php') or die(mysql_error());

What that seems to be saying is, "If the header command returns FALSE, terminate the script and print out whatever is in the mysql_error() function.  Why would you want to do that?
0
 
phillystyle123Author Commented:
or exit("unable to open file ($filename)");  ??
0
 
Ray PaseurCommented:
The "or" construct says, in effect, "Try this and if it returns FALSE, do the thing after the "or"

Why would you expect header("Location: ") to return FALSE?
0
 
phillystyle123Author Commented:
can you steer me toward a webpage that lists verious opitons and explains the die comand?
0
 
Ray PaseurCommented:
die() is equivalent to exit.  See http://us2.php.net/manual/en/function.exit.php

header("Location: ... "); tells the browser to fetch its next page from somewhere else.
See: http://us2.php.net/manual/en/function.header.php
And: http://www.faqs.org/rfcs/rfc2616

Let's go back to what you're trying to achieve.  You want to generate a PDF and send it to a client.  Sometimes that fails.  I think you should write your PDF to the server so you can look at it.  Perhaps if you can look at it after success and again after failure, you can discern differences in the PDF or the process that made it.

Best of luck with it, ~Ray
0
 
phillystyle123Author Commented:
This is what I've come up with - seems to be working thus far:

$mail->send($to, $hdrs, $body);

header ('Location: http://cornerstonesurgerycenter.com/survey_thanks.php')
or exit("unable to send pdf ($mail)");
0
 
Ray PaseurCommented:
Cool!  I love it when a plan starts to come together.  Thanks for the points, ~Ray
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now