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 = "[email protected]"; $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("[email protected]", "Reply"); //CC and BCC //$mail->addCC("[email protected]"); //$mail->addBCC("[email protected]"); //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();
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 = "[email protected]"; $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("[email protected]", "Reply"); //CC and BCC //$mail->addCC("[email protected]"); //$mail->addBCC("[email protected]"); //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();
Share Improve this question edited Sep 6, 2019 at 23:36 PratapAmitSingh asked Sep 6, 2019 at 22:52 PratapAmitSinghPratapAmitSingh 114 bronze badges 01 Answer
Reset to default 0I 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745162053a4614430.html
评论列表(0条)