cjbeck71081 Posted January 12, 2007 Share Posted January 12, 2007 I used PHP Mailer to create a script that took the contents of a order form and passed it through the script and Emailed it to a user. I have a couple of things i want to do to streamline the process, and maybe get more out of it. Some of these things might not be possible.Here is the page [url=http://www.epicri.com/dtcc]www.epicri.com/dtcc[/url]1. Once you see my code you will notice that rather than passing the variables from the PHP script and into an HTML template i have just copy and pasted the HTML code right into the body of the script. Is it possible to pass the information to an HTML template instead?(this question works with my next one i think)2. I would like to insert only the variables that have a Quantity of greater than 0 into the HTML template, so that the user on the other end gets only the items ordered emailed to them, not the whole list filled with mostly 0's3. Is there any way to pass one form through one template and email to one user, and then pass that same form through a second template to a second user??Honestly, working for clients is the most agonizing thing ever, they think just cause you can do one thing you are superman. I appreciate the help guys you are CHAMPS!!!Here is the code:[code]<?phprequire("class.phpmailer.php");$mail = new PHPMailer();$mail->IsSMTP(); // telling the class to use SMTP$mail->Host = "mail.epicri.com"; // SMTP server$mail->From = "[email protected]";$mail->AddAddress("[email protected]");$date = date("l jS F Y, ");$gim = date('g');$fix = $gim+7;$time = date(':i:s a');$qty1=$_POST['qty1'];$qty2=$_POST['qty2'];$qty3=$_POST['qty3'];$qty4=$_POST['qty4'];$qty5=$_POST['qty5'];$qty6=$_POST['qty6'];$qty7=$_POST['qty7'];$qty8=$_POST['qty8'];$qty9=$_POST['qty9'];$qty10=$_POST['qty10'];$qty11=$_POST['qty11'];$tot1=$_POST['tot1'];$tot2=$_POST['tot2'];$tot3=$_POST['tot3'];$tot4=$_POST['tot4'];$tot5=$_POST['tot5'];$tot6=$_POST['tot6'];$tot7=$_POST['tot7'];$tot8=$_POST['tot8'];$tot9=$_POST['tot9'];$tot10=$_POST['tot10'];$tot11=$_POST['tot11'];$gtotal=$_POST['gtotal'];$name=$_POST['name'];$num1=$_POST['num1'];$num2=$_POST['num2'];$num3=$_POST['num3'];$num4=$_POST['num4'];$fax1=$_POST['fax1'];$fax2=$_POST['fax2'];$fax3=$_POST['fax3'];$floor=$_POST['floor'];$costctr=$_POST['costctr'];$email=$_POST['email'];$auth=$_POST['auth'];$shipto=$_POST['shipto'];$inst=$_POST['inst'];$mail->IsHTML(true); $mail->Subject = "Supplies Order";$mail->Body = <<<HTML<p><br /> <font face="Arial" size="3"><b>$date $fix$time<br>DTCC Supplies Order Form</b></font></p><table width="650" border="1" cellpadding="0"> <tr> <td class="style1">Description</td> <td width="102" class="style1">Part # </td> <td width="56" class="style1">Qty</td> <td width="126" class="style1">Price</td> <td width="52" class="style1">Total</td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">IMAGING UNIT, LDC-600 SERIES</font> </td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">63582010</font></div></td> <td><div align="center">$qty1</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$215.00 ea</font> </div></td> <td><div align="left">$tot1</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">TONER CART, LDC-700 SERIES</font> </td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">37081011</font></div></td> <td><div align="center">$qty2</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$41.95 ea</font> </div></td> <td><div align="left">$tot2</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">IMAGING UNIT LDC-700 SERIES</font> </td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">68882020 </font></div></td> <td><div align="center">$qty3</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$345.00 ea</font> </div></td> <td><div align="left">$tot3</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">TONER CARD, LDC-850/870 SERIES</font> </td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">37017011 </font></div></td> <td><div align="center">$qty4</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$41.95 ea</font> </div></td> <td><div align="left">$tot4</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">IMAGING UNIT LDC-850/870 SERIES</font> </td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">2AN82010 </font></div></td> <td><div align="center">$qty5</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$225.00 ea</font> </div></td> <td><div align="left">$tot5</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">EJECTION TRAY, LDC-600 SERIES</font> </td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">63504133 </font></div></td> <td><div align="center">$qty6</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$24.95 ea</font> </div></td> <td><div align="left">$tot6</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">TONER KM-F650 </font></td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">TK-40</font></div></td> <td><div align="center">$qty7</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$185.00 ea</font> </div></td> <td><div align="left">$tot7</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">TONER KM-F1050 </font></td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">TK-45</font></div></td> <td><div align="center">$qty8</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$168.00 ea</font> </div></td> <td><div align="left">$tot8</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">TONER KM-F1060</font></td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">TD-47</font></div></td> <td><div align="center">$qty9</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$147.00 ea</font> </div></td> <td><div align="left">$tot9</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">TONER XEROX PHASER 4400 HY</font> </td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">113R000628</font> </div></td> <td><div align="center">$qty10</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$184.00 ea</font> </div></td> <td><div align="left">$tot10</div></td> </tr> <tr> <td width="297" align="left" class="style5"><font face="Arial" size="3">TONER XEROX PHASER 4500 HY</font> </td> <td align="left" width="102"><div align="center"><font face="Arial" size="3">113R000657</font> </div></td> <td><div align="center">$qty11</div></td> <td width="126" align="left"><div align="center"><font face="Arial" size="3">$230.00 ea</font> </div></td> <td><div align="left">$tot11</div></td> </tr> <tr> <td colspan="3"> </td> <td align="left"><div align="right"><b><font face="Times New Roman">Total Order:</font></b> </div></td> <td>$gtotal</td> </tr></table><p> </p><table width="678" border="1" cellpadding="0"> <tr> <td width="289" align="left" class="style5"><font face="Arial" size="3">Name:</font> </td> <td width="377">$name</td> </tr> <tr> <td width="289"><font face="Arial" size="3">PHONE NUMBER</font></td> <td width="377">($num1)$num2-$num3 Ext:$num4</td> </tr> <tr> <td width="289"><font face="Arial" size="3">FAX NUMBER:</font></td> <td width="377">($fax1)$fax2-$fax3</td> </tr> <tr> <td width="289"><font face="Arial" size="3">FLOOR:</font></td> <td width="377">$floor</td> </tr> <tr> <td width="289"><font face="Arial" size="3">COST CENTER:</font></td> <td width="377">$costctr</td> </tr> <tr> <td width="289"><font face="Arial" size="3">EMAIL:</font></td> <td width="377">$email</td> </tr> <tr> <td width="289"><font face="Arial" size="3">AUTHORIZED BY:</font></td> <td width="377">$auth</td> </tr> <tr> <td width="289"><font face="Arial" size="3">SHIP TO:;</font></td> <td width="377">$shipto</td> </tr> <tr> <td width="289"><font face="Arial" size="3"> SPECIAL INSTRUCTIONS/<br /> </font><font face="Arial" size="3">COMMENTS:<br /> </font></td> <td width="377">$inst</td> </tr></table><p> </p><p> </p></body>HTML;$mail->WordWrap = 50;if(!$mail->Send()){ echo "Message was not sent"; echo "Mailer Error: " . $mail->ErrorInfo;}else{ echo "Message has been sent";}?> [/code] Link to comment https://forums.phpfreaks.com/topic/33920-php-mailer-working-trying-to-format-it/ Share on other sites More sharing options...
AV1611 Posted January 12, 2007 Share Posted January 12, 2007 [quote]1. Once you see my code you will notice that rather than passing the variables from the PHP script and into an HTML template i have just copy and pasted the HTML code right into the body of the script. Is it possible to pass the information to an HTML template instead?(this question works with my next one i think)2. I would like to insert only the variables that have a Quantity of greater than 0 into the HTML template, so that the user on the other end gets only the items ordered emailed to them, not the whole list filled with mostly 0's3. Is there any way to pass one form through one template and email to one user, and then pass that same form through a second template to a second user??[/quote]I don't really understand the question, but here's my answer of what I think you mean:1. Yes. You can have several html templates as text files, then some code to determine which template to use, then read that file and insert it into the page, that's just one of many ways.2. simple clauses in the code to only set the variable if the amount > 0, etc.3. yes, put a fork in your code. the variables stay alive for the life of the page, or you can pass them to another page with sessions. Link to comment https://forums.phpfreaks.com/topic/33920-php-mailer-working-trying-to-format-it/#findComment-159246 Share on other sites More sharing options...
cjbeck71081 Posted January 12, 2007 Author Share Posted January 12, 2007 Would the best way to use those templates be the "Include" functions??What would be the best way to code a fork in my code to pass them in different directions? Link to comment https://forums.phpfreaks.com/topic/33920-php-mailer-working-trying-to-format-it/#findComment-159282 Share on other sites More sharing options...
AV1611 Posted January 12, 2007 Share Posted January 12, 2007 I've done it before... I had a single script send the output to two differnent iframes... you just do one thing, carry over the variables then do the other thing... Link to comment https://forums.phpfreaks.com/topic/33920-php-mailer-working-trying-to-format-it/#findComment-159441 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.