第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

我怎樣才能從 phpmailer 中的輸入中給出主題和正文消息

我怎樣才能從 phpmailer 中的輸入中給出主題和正文消息

PHP
慕田峪4524236 2023-08-11 16:41:29
這是index.php 現(xiàn)在我所能做的就是給 $mail->Subject 和 $mail->body 賦值,但我希望它是動(dòng)態(tài)的,例如在這里我想為主題和消息提供 2 個(gè)輸入并傳遞它在 $mail->Subject 和 $mail->Body 上,因?yàn)?post 方法是在 ajax 上,我無法將兩個(gè)值從輸入字段傳遞到 send_mail.php 任何幫助將不勝感激<?php    //index.php        $connect = new PDO("mysql:host=localhost;dbname=testing", "root", "");    $query = "SELECT * FROM customer ORDER BY customer_id";    $statement = $connect->prepare($query);    $statement->execute();    $result = $statement->fetchAll();        ?>    <!DOCTYPE html>    <html>    <head>               <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" />        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>    </head>    <body>    <br />    <div class="container">              <br />        <div class="table-responsive">                <table class="table table-bordered table-striped">                <tr>                    <th>Customer Name</th>                    <th>Email</th>                    <th>Select</th>                    <th>Action</th>                </tr>
查看完整描述

2 回答

?
溫溫醬

TA貢獻(xiàn)1752條經(jīng)驗(yàn) 獲得超4個(gè)贊

我假設(shè)您想為每封電子郵件數(shù)據(jù)的主題和消息添加兩個(gè)輸入。


您可以添加 2 個(gè)字段,并在 ajax 中將其與電子郵件數(shù)據(jù)一起設(shè)置并將其傳遞給 send_mail.php。


JS代碼


<script>

    $(document).ready(function(){

        $('.email_button').click(function(){

            $(this).attr('disabled', 'disabled');

            var id  = $(this).attr("id");

            var action = $(this).data("action");

            var email_data = [];

            if(action == 'single')

            {

                email_data.push({

                    email: $(this).data("email"),

                    name: $(this).data("name"),

                    subject: $(this).data("subject"), //or can be grab from input

                    message: $(this).data("message")

                });

            }

            else

            {

                $('.single_select').each(function(){

                    if($(this).prop("checked") == true)

                    {

                        email_data.push({

                            email: $(this).data("email"),

                            name: $(this).data('name'),

                            subject: $(this).data("subject"), //or can be grab from input

                    message: $(this).data("message")

                        });

                    }

                });

            }


            $.ajax({

                url:"send_mail.php",

                method:"POST",

                data:{email_data:email_data},

                beforeSend:function(){

                    $('#'+id).html('Sending...');

                    $('#'+id).addClass('btn-danger');

                },

                success:function(data){

                    if(data == 'ok')

                    {

                        $('#'+id).text('Success');

                        $('#'+id).removeClass('btn-danger');

                        $('#'+id).removeClass('btn-info');

                        $('#'+id).addClass('btn-success');

                    }

                    else

                    {

                        $('#'+id).text(data);

                    }

                    $('#'+id).attr('disabled', false);

                }

            })


        });

    });

</script>

在 send_mail.php 中替換以下行


$mail->Subject = 'i want input to be passed here'; 

//An HTML or plain text message body

$mail->Body = 'and the body message to be passed here';

有了這個(gè)


$mail->Subject = $row["subject"]; 

$mail->Body = $row["message"];

希望它能回答您的問題。


查看完整回答
反對 回復(fù) 2023-08-11
?
偶然的你

TA貢獻(xiàn)1841條經(jīng)驗(yàn) 獲得超3個(gè)贊

首先:使用ajax僅發(fā)送用戶id(最好在js中使用fetch()來請求),然后從數(shù)據(jù)庫中獲取文件(send_mail.php)中的用戶數(shù)據(jù)(用戶驗(yàn)證)!

如果不是通過會(huì)話,則需要通過檢查數(shù)據(jù)庫來進(jìn)行用戶驗(yàn)證。

查看完整回答
反對 回復(fù) 2023-08-11
  • 2 回答
  • 0 關(guān)注
  • 125 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號