elentz Posted January 23, 2008 Share Posted January 23, 2008 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 = "sales@comm.biz"; $mail->FromName = (" Sales Dept."); $mail->AddAddress("$emailto"); $mail->AddReplyTo("sales@comm.biz" ); $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 Quote Link to comment https://forums.phpfreaks.com/topic/87299-solved-if-statement-within-an-if-statement/ Share on other sites More sharing options...
interpim Posted January 23, 2008 Share Posted January 23, 2008 sounds like an normal if statement to me... if(condition){ stuff to do; }else{ other stuff; } Quote Link to comment https://forums.phpfreaks.com/topic/87299-solved-if-statement-within-an-if-statement/#findComment-446542 Share on other sites More sharing options...
revraz Posted January 23, 2008 Share Posted January 23, 2008 You already gave your own example IF ($sendtobilltoemail ==1) { $variable1 = $variable 2; } else { $variable1 = $variable3; } Quote Link to comment https://forums.phpfreaks.com/topic/87299-solved-if-statement-within-an-if-statement/#findComment-446545 Share on other sites More sharing options...
elentz Posted January 23, 2008 Author Share Posted January 23, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/87299-solved-if-statement-within-an-if-statement/#findComment-446598 Share on other sites More sharing options...
Ken2k7 Posted January 23, 2008 Share Posted January 23, 2008 if($usebilltoemail == 1) {$sendemailto = $mainemail} Should be: if($usebilltoemail == 1) {$sendemailto = $mainemail;} Semicolon Quote Link to comment https://forums.phpfreaks.com/topic/87299-solved-if-statement-within-an-if-statement/#findComment-446600 Share on other sites More sharing options...
elentz Posted January 24, 2008 Author Share Posted January 24, 2008 DOH! I guess I need bigger font or better glasses! Thanks for seeing that! Quote Link to comment https://forums.phpfreaks.com/topic/87299-solved-if-statement-within-an-if-statement/#findComment-447778 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.