简体   繁体   English

将HTML代码的DIV块分配给PHP变量

[英]Assigning a DIV block of HTML code to a PHP variable

How can I reference the below div using the ID as a PHP variable is the same script? 如何使用ID作为PHP变量的同一脚本引用下面的div?

<?php

    $variableIDqamaildiv -> How should I assign it to the DIV with the ID below

?>

<div contentEditable="true" class="qamaildiv" id="qamaildiv">

  Dear <?php echo $ccname; ?>,<br><br>

  Regarding QA of Canvas ID: <?php echo $courseTerm;?><br><br>

  <p>Students will now be given access to the Canvas course shell seven days prior to the class start date.</p>

  <p>If you have any questions, please contact <a href="mailto:abc@abc.com?Subject=QA%20Query%20regarding%20<?php echo $_POST['code_term']?>">abc@abc.com</a>.</p>

  Kind Regards,<br><br>
  INSERT SIGNATURE

</div>

Below is a working example. 下面是一个工作示例。 Although you would need to refine it. 尽管您需要对其进行优化。

<script type="text/javascript">

function sendEmail(){

elm = document.getElementById('send_email');
elm.href = "mailto:abc@abc.com?subject=subject of the email&body="+ document.getElementById('qamaildiv').innerHTML;
}
</script>
</head>

<body>

<a href="#" onclick="return sendEmail();" id="send_email">Send Email</a>
<div contentEditable="true" class="qamaildiv" id="qamaildiv" >

  Dear <?php echo $ccname; ?>,<br><br>

  Regarding QA of Canvas ID: <?php echo $courseTerm;?><br><br>

  <p>Students will now be given access to the Canvas course shell seven days prior to the class start date.</p>

  <p>If you have any questions, please contact <a href="mailto:abc@abc.com?Subject=QA%20Query%20regarding%20<?php echo $_POST['code_term']?>">abc@abc.com</a>.</p>

  Kind Regards,<br><br>
  INSERT SIGNATURE

</div>
</body>
</html>

I used the following solution to send the email. 我使用以下解决方案发送电子邮件。 Thank you, everyone, for lending your helping hand. 谢谢大家,帮助您。 I need help with how I can reference I want to reference the <DIV> with ID=qamaildiv as a PHP variable at the top of this script. 我需要如何引用的帮助,我想在此脚本的顶部引用ID=qamaildiv<DIV>作为PHP变量。 How can I represent a block of HTML code as a PHP variable as explained above? 如上所述,如何将HTML代码块表示为PHP变量?

Thank you in advance. 先感谢您。

<?php

// My initial PHP code. Removing it here because of privacy concerns. :)
// Then added the PHP mailer

// Import PHPMailer classes into the global namespace
// These must be at the top of your script, not inside a function
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

//Load Composer's autoloader
require 'vendor/autoload.php';

$mail = new PHPMailer(true);                              // Passing `true` enables exceptions
$mail;
try {
    //Server settings
    $mail->SMTPDebug = 1;                              // Enable verbose debug output
    $mail->isSMTP();                                      // Set mailer to use SMTP
    $mail->Host = 'HOSTNAME';  // Specify main and backup SMTP servers
    $mail->SMTPAuth = true;                               // Enable SMTP authentication
    $mail->Username = 'USER EMAIL ID';          // SMTP username
    $mail->Password = 'PASSWORD';                           // SMTP password
    $mail->SMTPSecure = 'tls';          // Enable TLS encryption, `ssl` also accepted
    $mail->Port = 587;                                    // TCP port to connect to

    //Recipients
    $mail->setFrom('sendFROMemailID', 'Heading');
    $mail->addAddress('sendTOEMAILID','NAME');     // Add a recipient
//    $mail->addAddress('ellen@example.com');               // Name is optional
//    $mail->addReplyTo('info@example.com', 'Information');
//    $mail->addCC('cc@example.com');
//    $mail->addBCC('bcc@example.com');

    //Attachments (if any)
      $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
      $mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name

    //Content
    $mail->isHTML(true);                                  // Set email format to HTML
    $mail->Subject = 'Here is the subject';
    $mail->Body    = 'This is the HTML message body <b>in bold!</b>';
    $mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

    $mail->send();
    echo 'Message has been sent';
} catch (Exception $e) {
    echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}


?>


<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Congratulations!</title>

</head>
<body>

<div>
<form method="post" action="publishqa_true.php">
<div contentEditable="true" class="qamaildiv" id="qamaildiv">

Dear ,<br><br>

Regarding QA of Canvas ID: <?php echo $Term;?><br><br>

<p>We are very pleased to say that your above course has satisfied all blah Success and therefore is ready to teach out of Canvas.</p>

<p>Students will now be given access to the blah course shell seven days prior to the class start date.</p>

<p>We would like to sincerely thank you for all of your efforts in embracing blah and helping to improve the blah experience. We provided our personal notes for each of the blah below:</p>


Kind Regards,<br><br>
INSERT SIGNATURE<br>

</div><br>


<input class="ch-button" type="submit" name="submit" value="Send Email">

</form>
</div>


</body>
</html>


// Prewritten footer file loading at the bottom of this file
<?php require_once("../private/layout/footer.php"); ?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM