Server IP : 103.53.40.154 / Your IP : 18.191.237.228 Web Server : Apache System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : ppcad7no ( 715) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0750) : /home2/ppcad7no/adisgauges.com/../www/../thedigitalgulf.com/../deedeecreation.in/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php ini_set('display_errors', 1); // use these lines to know the error that you are getting error_reporting(E_ALL); // Both these lines are to know about the error is not visible include_once('admin/config.php'); $name = mysqli_real_escape_string($db, $_POST['cust_name']); $phone = mysqli_real_escape_string($db, $_POST['phone']); $email = mysqli_real_escape_string($db, $_POST['email']); $city = mysqli_real_escape_string($db, $_POST['city']); $address = mysqli_real_escape_string($db, $_POST['address']); include 'top-link.php'; require 'vendor/autoload.php'; ob_start(); // Your existing loop to generate product information foreach ($_SESSION['cart'] as $key => $value) { $imageUrl = $wspath . 'admin/images/' . $value['img1']; echo '<div> <div style="display: flex; flex-direction: column; align-items: center; text-align: center; padding:30px 0; border-bottom: 1px solid gray;"> <img style="width: 180px; display: block; margin: 10px auto 0;" src="http://www.deedeecreation.in/admin/images/dee-logo.jpg"> </div> <div style="display: flex; align-items: center; margin-bottom: 10px; border-bottom: 1px solid #000;"> <img style="width: 84px; display: block; margin-right: 10px;" src="' . $imageUrl . '"> <div style="margin-top:-120px;"> <span style="display: block; text-align: center; padding-right: 10px; padding-bottom:30px;"><b style="padding-right:20px;">Design:</b> ' . $value['name'] . '</span> <span style="display: block; text-align: center; padding-right: 10px; padding-bottom:30px;"><b style="padding-right:20px;">Size:</b> ' . $value['size'] . '</span> <span style="display: block; text-align: center; padding-right: 10px; padding-bottom:40px;"><b style="padding-right:20px;">Rate:</b> ' . $value['rate'] . '</span> </div> </div> </div>'; } $html = ob_get_clean(); try { $options = new \Dompdf\Options(); $options->set('debugKeepTemp', true); // Set the debug option $options->set('isHtml5ParserEnabled', true); $options->set('isRemoteEnabled', true); $dompdf = new \Dompdf\Dompdf($options); $dompdf->setBasePath($wspath); $dompdf->loadHtml($html); $dompdf->setPaper('A4', 'portrait'); $dompdf->render(); $output = $dompdf->output(); $currentDateTime = (new \DateTime())->format('Ymd_His'); $pdfFileName = "generated_invoice_$currentDateTime.pdf"; $pdfPath = "img/$pdfFileName"; file_put_contents($pdfPath, $output); // Send email with attachment using mail() function $toInfo = 'morphykids@gmail.com'; // $toInfo = 'digitalsaleem12@gmail.com'; $ccInfo = $email; // Replace with the CC email address $subjectInfo = 'Generated Products PDF File'; $messageInfo = 'Please find the attached Products PDF File.' . "\n\n"; $messageInfo .= "Name: " . $name . "\n"; $messageInfo .= "Phone: " . $phone . "\n"; $messageInfo .= "Email: " . $email . "\n"; $messageInfo .= "City: " . $city . "\n"; $messageInfo .= "Address: " . $address . "\n"; $headersInfo = "From: $email\r\n"; $headersInfo .= "Reply-To: $email\r\n"; if (!empty($ccInfo)) { $headersInfo .= "Cc: $ccInfo\r\n"; // Add the CC header if provided } $boundary = md5(time()); $headersInfo .= "MIME-Version: 1.0\r\n"; $headersInfo .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\r\n"; $attachment = chunk_split(base64_encode(file_get_contents($pdfPath))); $bodyInfo = "--$boundary\r\n"; $bodyInfo .= "Content-Type: text/plain; charset=\"utf-8\"\r\n"; $bodyInfo .= "Content-Transfer-Encoding: 7bit\r\n\r\n"; $bodyInfo .= $messageInfo . "\r\n\r\n"; $bodyInfo .= "--$boundary\r\n"; $bodyInfo .= "Content-Type: application/pdf; name=\"$pdfFileName\"\r\n"; $bodyInfo .= "Content-Disposition: attachment; filename=\"$pdfFileName\"\r\n"; $bodyInfo .= "Content-Transfer-Encoding: base64\r\n\r\n"; $bodyInfo .= chunk_split(base64_encode(file_get_contents($pdfPath)), 76, "\r\n"); $bodyInfo .= "--$boundary--"; $emailSentToInfo = mail($toInfo, $subjectInfo, $bodyInfo, $headersInfo); if ($emailSentToInfo) { $pdfFileNameDB = mysqli_real_escape_string($db, $pdfFileName); // Insert into the database $insertQuery = "INSERT INTO `tbl_booking`(`name`, `email`, `phone`, `city`, `address`, `attachment`) VALUES ('$name', '$email', '$phone','$city', '$address', '$pdfFileNameDB')"; $insertResult = mysqli_query($db, $insertQuery); if ($insertResult) { session_unset(); echo '<script>'; echo 'alert("Email Sent You and Dee Dee Creation. Check your email for confirmation. We will contact you soon.");'; echo 'window.history.back();'; echo '</script>'; } else { echo '<script>'; echo 'alert("Failed to Sent Email Try again.");'; echo '</script>'; } } else { echo '<script>'; echo 'alert("Email could not be sent. Try again with all required fields.");'; echo 'window.history.back();'; echo '</script>'; } } catch (\Exception $e) { echo "An error occurred: " . $e->getMessage(); } exit; ?>