Jump to content

[SOLVED] If Statement within an if statement


elentz

Recommended Posts

First of all the code I am going to paste here is just for show.  I got phpmailer working mostly the way I want it, I just need help with if / else statements.  I have a if /else statement that will determine if I want to email the pdf or download it and this is working fine.  What I can't figure out is how to change the variables within the if statement to send the email.  Such as IF $sendtobilltoemail ==1  ($variable1 = $variable 2)

else $variable1 = $variable3

 

I have a couple of these types of things I need to do within the statement to send the pdf as an email

 

//*********if / Else statement to send email to the Bill TO email address or a user input email address ********
//if($usebilltoemail == 1) {$sendemailto = $mainemail}
//else {$sendemailto = $emailto;}



//******if /Else to determine whether to send the pdf in a email or not ********
if($emailpdf == 1){


//****************Code to create the PDF as a string variale so it can be emailed ***********

$pdf->Output("","S");
$doc = $pdf->Output("","S");

//*******************Setup and send the PDF as an attachment***************

require("/var/customstuff/PHPMailer/class.phpmailer.php");
//$mail->PluginDir = "/var//PHPMailer";
$mail = new PHPMailer();
$mail->From = "[email protected]";
$mail->FromName = (" Sales Dept.");
$mail->AddAddress("$emailto");
$mail->AddReplyTo("[email protected]" );
$mail->Subject = ("Here is the proposal you requested.");
$mail->Body = "Hello, $contact_name
Please read over the enclosed proposal.  
I have also included a  brochure about our company.

If you have any questions Please contact me.

Thank you very much for this opportunity!

Sincerely,
$salesman

;

$mail->AddStringAttachment($doc,"Proposal # $quote_id.pdf","base64","MIME");

$mail->AddAttachment("/var/www/include/Quote_attachments/CQI_Brochure.pdf","CQI Brochure.pdf"); //Adds a file to the email automatically
if(!$mail->Send())
{

echo "Message could not be sent. <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}

echo "The Proposal has been sent, use your back button to return to the last page.";
}
else {
// ****************** Code to create the pdf to be downloaded *******************************

$pdf->Output('Proposal # '.$quote_id.' For '.$account_name.'.pdf','D');
}

?>

 

Can someone show me an example of how to do this?

 

Thanks alot

I must not be explaining what I need to do correctly.

 

In the code I provided I have a IF/else :

 

if($usebilltoemail == 1) {$sendemailto = $mainemail}

else {$sendemailto = $emailto;}

 

What I needed the above to do was give me a way to change the sendemailto to different addresses.  When I tried to use the above code everything failed, do I have some syntax error?

 

Thanks

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.