Guest User

Untitled

a guest
Dec 22nd, 2015
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.40 KB | None | 0 0
  1. <?php
  2. $con = mysqli_connect ('localhost','amtaarg1','@Za2011467','amtaarg1_amtargc');
  3.  
  4. if (mysqli_connect_errno()){
  5.    
  6.     echo 'Failed to establish a connection:' .mysqli_connect_errno();
  7. }
  8.  
  9.  
  10.  $sql='SELECT * FROM orders T1 join users T2 ON T1.client_id=T2.User_id JOIN invoice T3 ON T3.o_id=T1.order_id  WHERE T1.order_id=1';
  11. $query=mysqli_query($con,$sql);
  12.  
  13. $row=mysqli_fetch_assoc($query);
  14. $total_payment=$row['total_payment'];
  15. $vinvoice_id=$row['invoice_id'];
  16. $date=$row['date'];
  17. $username=$row['User_firstName'];
  18. $User_Address1=$row['User_Address1'];
  19. $User_Country=$row['User_Country'];
  20. $address=$User_Address1 .'   '. $User_Country;
  21.  $message="<html>
  22. <head>
  23. <meta name='viewport' content='width=device-width' />
  24. <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
  25. <title>Send Emails</title>";
  26.  
  27.  
  28.  $message .="<style>
  29. /* -------------------------------------
  30.    GLOBAL
  31.    A very basic CSS reset
  32. ------------------------------------- */
  33. * {
  34.  margin: 0;
  35.  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  36.  box-sizing: border-box;
  37.  font-size: 14px;
  38. }
  39.  
  40. img {
  41.  max-width: 100%;
  42. }
  43.  
  44. body {
  45.  -webkit-font-smoothing: antialiased;
  46.  -webkit-text-size-adjust: none;
  47.  width: 100% !important;
  48.  height: 100%;
  49.  line-height: 1.6em;
  50.  /* 1.6em * 14px = 22.4px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */
  51.  /*line-height: 22px;*/
  52. }
  53.  
  54. /* Let's make sure all tables have defaults */
  55. table td {
  56.  vertical-align: top;
  57. }
  58.  
  59. /* -------------------------------------
  60.    BODY & CONTAINER
  61. ------------------------------------- */
  62. body {
  63.  background-color: #f6f6f6;
  64. }
  65.  
  66. .body-wrap {
  67.  background-color: #f6f6f6;
  68.  width: 100%;
  69. }
  70.  
  71. .container {
  72.  display: block !important;
  73.  max-width: 600px !important;
  74.  margin: 0 auto !important;
  75.  /* makes it centered */
  76.  clear: both !important;
  77. }
  78.  
  79. .content {
  80.  max-width: 600px;
  81.  margin: 0 auto;
  82.  display: block;
  83.  padding: 20px;
  84. }
  85.  
  86. /* -------------------------------------
  87.    HEADER, FOOTER, MAIN
  88. ------------------------------------- */
  89. .main {
  90.  background-color: #fff;
  91.  border: 1px solid #e9e9e9;
  92.  border-radius: 3px;
  93. }
  94.  
  95. .content-wrap {
  96.  padding: 20px;
  97. }
  98.  
  99. .content-block {
  100.  padding: 0 0 20px;
  101. }
  102.  
  103. .header {
  104.  width: 100%;
  105.  margin-bottom: 20px;
  106. }
  107.  
  108. .footer {
  109.  width: 100%;
  110.  clear: both;
  111.  color: #999;
  112.  padding: 20px;
  113. }
  114. .footer p, .footer a, .footer td {
  115.  color: #999;
  116.  font-size: 12px;
  117. }
  118.  
  119. /* -------------------------------------
  120.    TYPOGRAPHY
  121. ------------------------------------- */
  122. h1, h2, h3 {
  123.  font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
  124.  color: #000;
  125.  margin: 40px 0 0;
  126.  line-height: 1.2em;
  127.  font-weight: 400;
  128. }
  129.  
  130. h1 {
  131.  font-size: 32px;
  132.  font-weight: 500;
  133.  /* 1.2em * 32px = 38.4px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */
  134.  /*line-height: 38px;*/
  135. }
  136.  
  137. h2 {
  138.  font-size: 24px;
  139.  /* 1.2em * 24px = 28.8px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */
  140.  /*line-height: 29px;*/
  141. }
  142.  
  143. h3 {
  144.  font-size: 18px;
  145.  /* 1.2em * 18px = 21.6px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */
  146.  /*line-height: 22px;*/
  147. }
  148.  
  149. h4 {
  150.  font-size: 14px;
  151.  font-weight: 600;
  152. }
  153.  
  154. p, ul, ol {
  155.  margin-bottom: 10px;
  156.  font-weight: normal;
  157. }
  158. p li, ul li, ol li {
  159.  margin-left: 5px;
  160.  list-style-position: inside;
  161. }
  162.  
  163. /* -------------------------------------
  164.    LINKS & BUTTONS
  165. ------------------------------------- */
  166. a {
  167.  color: #348eda;
  168.  text-decoration: underline;
  169. }
  170.  
  171. .btn-primary {
  172.  text-decoration: none;
  173.  color: #FFF;
  174.  background-color: #348eda;
  175.  border: solid #348eda;
  176.  border-width: 10px 20px;
  177.  line-height: 2em;
  178.  /* 2em * 14px = 28px, use px to get airier line-height also in Thunderbird, and Yahoo!, Outlook.com, AOL webmail clients */
  179.  /*line-height: 28px;*/
  180.  font-weight: bold;
  181.  text-align: center;
  182.  cursor: pointer;
  183.  display: inline-block;
  184.  border-radius: 5px;
  185.  text-transform: capitalize;
  186. }
  187.  
  188. /* -------------------------------------
  189.    OTHER STYLES THAT MIGHT BE USEFUL
  190. ------------------------------------- */
  191. .last {
  192.  margin-bottom: 0;
  193. }
  194.  
  195. .first {
  196.  margin-top: 0;
  197. }
  198.  
  199. .aligncenter {
  200.  text-align: center;
  201. }
  202.  
  203. .alignright {
  204.  text-align: right;
  205. }
  206.  
  207. .alignleft {
  208.  text-align: left;
  209. }
  210.  
  211. .clear {
  212.  clear: both;
  213. }
  214.  
  215. /* -------------------------------------
  216.    ALERTS
  217.    Change the class depending on warning email, good email or bad email
  218. ------------------------------------- */
  219. .alert {
  220.  font-size: 16px;
  221.  color: #fff;
  222.  font-weight: 500;
  223.  padding: 20px;
  224.  text-align: center;
  225.  border-radius: 3px 3px 0 0;
  226. }
  227. .alert a {
  228.  color: #fff;
  229.  text-decoration: none;
  230.  font-weight: 500;
  231.  font-size: 16px;
  232. }
  233. .alert.alert-warning {
  234.  background-color: #FF9F00;
  235. }
  236. .alert.alert-bad {
  237.  background-color: #D0021B;
  238. }
  239. .alert.alert-good {
  240.  background-color: #68B90F;
  241. }
  242.  
  243. /* -------------------------------------
  244.    INVOICE
  245.    Styles for the billing table
  246. ------------------------------------- */
  247. .invoice {
  248.  margin: 40px auto;
  249.  text-align: left;
  250.  width: 80%;
  251. }
  252. .invoice td {
  253.  padding: 5px 0;
  254. }
  255. .invoice .invoice-items {
  256.  width: 100%;
  257. }
  258. .invoice .invoice-items td {
  259.  border-top: #eee 1px solid;
  260. }
  261. .invoice .invoice-items .total td {
  262.  border-top: 2px solid #333;
  263.  border-bottom: 2px solid #333;
  264.  font-weight: 700;
  265. }
  266.  
  267. /* -------------------------------------
  268.    RESPONSIVE AND MOBILE FRIENDLY STYLES
  269. ------------------------------------- */
  270. @media only screen and (max-width: 640px) {
  271.  body {
  272.    padding: 0 !important;
  273.  }
  274.  
  275.  h1, h2, h3, h4 {
  276.    font-weight: 800 !important;
  277.    margin: 20px 0 5px !important;
  278.  }
  279.  
  280.  h1 {
  281.    font-size: 22px !important;
  282.  }
  283.  
  284.  h2 {
  285.    font-size: 18px !important;
  286.  }
  287.  
  288.  h3 {
  289.    font-size: 16px !important;
  290.  }
  291.  
  292.  .container {
  293.    padding: 0 !important;
  294.    width: 100% !important;
  295.  }
  296.  
  297.  .content {
  298.    padding: 0 !important;
  299.  }
  300.  
  301.  .content-wrap {
  302.    padding: 10px !important;
  303.  }
  304.  
  305.  .invoice {
  306.    width: 100% !important;
  307.  }
  308. }
  309.  
  310. /*# sourceMappingURL=styles.css.map */
  311.  
  312. </style>
  313. </head>";
  314.  
  315.  
  316. $message .="<body>
  317.  
  318. <table class='body-wrap'>
  319.     <tr>
  320.         <td></td>
  321.         <td class='container' width='600'>
  322.             <div class='content'>
  323.                 <table class='main' width='100%' cellpadding='0' cellspacing='0'>
  324.                     <tr>
  325.                         <td class='content-wrap aligncenter'>";
  326.                             $message .="<table width='100%' cellpadding='0' cellspacing='0'>
  327.                                 <tr>
  328.                                     <td class='content-block'>
  329.                                         <h1 class='aligncenter'></h1>
  330.                                     </td>
  331.                                 </tr>
  332.                                 <tr>
  333.                                     <td class='content-block'>
  334.                                         <h2 class='aligncenter'>Thanks for using AMGC.</h2>
  335.                                     </td>
  336.                                 </tr>";
  337.                                 $message .="<tr>
  338.                                     <td class='content-block aligncenter'>
  339.                                         <table class='invoice'>
  340.                                             <tr>
  341.                                                 <td>Customer Name  :$username<br><br>Invoice  :  #$vinvoice_id<br><br>Date :$date </td>
  342.                                             </tr>";
  343.                                             ?>
  344.                                             <?php
  345.                                             $sql2="SELECT * FROM `invoice` WHERE `invoice_id`='$vinvoice_id'";
  346.                                                     $qr2=mysqli_query($con,$sql2);
  347.                                                 while($row2=mysqli_fetch_assoc($qr2)){
  348.                                                     $product_name=$row2['product_name'];
  349.                                                     $price=$row2['price'];
  350.                                            
  351.                                             $message .="<tr>
  352.                                                 <td>
  353.                                                     <table class='invoice-items' cellpadding='0' cellspacing='0'>
  354.                                                         <tr>
  355.                                                             <td>$product_name</td>
  356.                                                             <td class='alignright'>AED  $price</td>
  357.                                                         </tr>";
  358.                                                 } ?>
  359.                                                 <?php
  360.                                                         $message .="<tr class='total'>
  361.                                                             <td class='alignright' width='80%'>Total</td>
  362.                                                             <td class='alignright'>AED  $total_payment</td>
  363.                                                         </tr>
  364.                                                     </table>
  365.                                                 </td>
  366.                                             </tr>
  367.                                         </table>
  368.                                     </td>
  369.                                 </tr>";
  370.                                 $message .="<tr>
  371.                                     <td class='content-block aligncenter'>
  372.                                         <a href='http://www.mailgun.com'>View in browser</a>
  373.                                     </td>
  374.                                 </tr>";
  375.                                 $message .="<tr>
  376.                                     <td class='content-block aligncenter'>
  377.                                         Shipping Addres: $address
  378.                                     </td>
  379.                                 </tr>
  380.                             </table>
  381.                         </td>
  382.                     </tr>
  383.                 </table>
  384.                 <div class='footer'>
  385.                     <table width='100%'>
  386.                         <tr>
  387.                             <td class='aligncenter content-block'>Any Questions? Email <a href='mailto:'>admin@amtargc.com</a></td>
  388.                         </tr>
  389.                     </table>
  390.                 </div></div>
  391.         </td>
  392.         <td></td>
  393.     </tr>
  394. </table>
  395.  
  396. </body>
  397. </html>";
  398. echo $message;
  399. require_once('class.phpmailer.php');
  400.  
  401. $mail             = new PHPMailer();
  402.  
  403.  
  404.  
  405. $mail->AddReplyTo("name@yourdomain.com","First Last");
  406.  
  407. $mail->SetFrom('admin@amtargc.com', 'AGC');
  408.  
  409. $mail->AddReplyTo("name@yourdomain.com","First Last");
  410.  
  411. $address = "nadeemflyer@gmail.com";
  412. $mail->AddAddress($address, "John Doe");
  413.  
  414. $mail->Subject    = "Voucher Details";
  415.  
  416. $mail->AltBody    = "To view the message, please use an HTML compatible email viewer!";
  417.  
  418. $mail->MsgHTML($message);
  419.  
  420. $mail->AddAttachment("images/phpmailer.gif");      
  421. $mail->AddAttachment("images/phpmailer_mini.gif");
  422.  
  423. if(!$mail->Send()) {
  424.   echo "Mailer Error: " . $mail->ErrorInfo;
  425. } else {
  426.   echo " Yes Message sent successfully!";
  427. }
  428.     ?>
Add Comment
Please, Sign In to add comment