0

I have customized the template and sending some value using POST method to each custom page. All custom page is working good except the last custom page where I need to insert the data with mail send option. It is working good when I browse the page but not with POST value.

I am using phpmailer for mail send.

/** * Template Name: Download Page **/ session_start(); get_header(); /*

*/ include 'connect.php'; if(isset($_POST['download'])){ $psize = $_SESSION['psize']; $size = $_SESSION['size']; $name = $_POST['name']; $mobile = $_POST['mobilephone']; $email_id= $_POST['emailid']; $size = $_SESSION['size']; $ctprice = $_POST['ctprice']; $appl = $_POST['appl']; $appln = $_POST['appln']; $image = stripslashes($_POST['image']); $filenameID = date('mdYHis') . mt_rand(6, 10); $total_sub1 = $size + $ctprice; // echo $total_sub1."
"; $total_sub2 =0; foreach($_POST['appl'] as $field) { if($field == '') { echo "error - doesn't have a value"; } else { $total_sub2+=$field; } } $total = $total_sub1 + $total_sub2; // echo $total."
"; for ($i = 0; $i '. $appln[$i].' INR '. $appl[$i].' '; //echo $Appliance; } } $filename = date('mdYHis'); require_once "PHPMailer/src/PHPMailer.php"; //PHPMailer Object $mail = new PHPMailer\PHPMailer\PHPMailer(); //From email address and name $mail->From = "no_reply@example.com"; $mail->FromName = "Customized Kitchen"; //To address and name $mail->addAddress($email_id, "Recepient Name"); $mail->addAddress($email_id); //Recipient name is optional //Address to which recipient will reply $mail->addReplyTo("no_reply@example.com", "Reply"); //CC and BCC //$mail->addCC("cc@example.com"); //$mail->addBCC("bcc@example.com"); //Send HTML or Plain Text email $mail->isHTML(true); $mail->Subject = 'Custom Kitchen'; $mail->Body = 'Content'; //$mail->AltBody = "This is the plain text version of the email content"; if(!$mail->send()) { // echo "Mailer Error: " . $mail->ErrorInfo; echo "Message has been failed"; echo '

Somthing went wrong. Your customization is not Saved.

For customisation Visit here -> Customize

'; } else { $sql = "INSERT INTO `enquiry`(`name`, `email`, `mobile`, `layout`,`fileID` ,`fileHTML`, `cost`, `total`) VALUES ('$name','$email_id','$mobile','$layout','$filenameID','$image','$total_sub1','$total')"; // echo $sql; $result = $connect->query($sql); if($result){ $msg = "success"; echo "Message has been sent successfully"; } else { $msg = "failed"; echo "

Please Try Again

"; } } } /* */ if(isset($_GET['file'])){ $file=$_GET['file']; // echo $file; $sql_file = "SELECT `fileHTML` FROM `enquiry` WHERE `fileId`='$file'"; // echo $sql_file; $res_file = $connect->query($sql_file); if ($res_file->num_rows > 0) { // output data of each row while($row_file = $res_file->fetch_assoc()){ // /* //
// Download */ } } } /*/

*/ get_footer();

0

I have fixed this issue. The issue was in variable $name and $name is reserved in wordpress. So I have changed it to $fname. And now it is working fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.