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

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

如何將數(shù)據(jù)從 jquery 傳遞到 php,以在 gmail 上發(fā)送消息

如何將數(shù)據(jù)從 jquery 傳遞到 php,以在 gmail 上發(fā)送消息

PHP
函數(shù)式編程 2021-10-22 10:17:24
你好只需要在gmail上發(fā)送消息。表單提交應(yīng)該使用 jQuery 來實(shí)現(xiàn)。我想我不能將數(shù)據(jù)從 jquery 傳遞到 php。沒有 jquery 文件的消息正在 gmail 上發(fā)送,但是當(dāng)我在 html 上包含 jquery 時(shí),它說消息已成功發(fā)送,但 gmail 上沒有任何顯示這是主要的 PHP 文件<?phprequire 'Sendmail.php';?><!doctype html><html><head>    <title>Contact Us</title></head><body><section>    <h1>Contact Form</h1>    <form action="" method="POST">            <label>Firstname</label>            <input type="text" name="firstname" id="firstname">            <label>Lastname</label>            <input type="text" name="lastname" id="lastname">            <label>Email</label>            <input type="text" name="email" id="email">            <label>Subject</label>            <input type="text" name="subject" id="subject">            <label>message</label>            <textarea name="message" id="message"></textarea>        <a href="index.php">Sign Up</a>        <button type="submit" id="button" name="submit" value="Send message">Send message</button>    </form></section><script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script><script type="text/javascript" src="ContactValidation.js"></script></body></html>這是在 gmail 上發(fā)送消息的 PHP 文件<?phperror_reporting(0);$firstname = $_POST['firstname'];$lastname = $_POST['lastname'];$email = $_POST['email'];$sub = $_POST['subject'];$message = $_POST['message'];if (isset($_POST['submit'])){    $to = 'g_chkuaseli@cu.edu.ge';    $subject = "Subject:  " . $sub ;    $subject2 = "Copy of your subject:  " . $sub;    $message = $firstname . $lastname . " wrote the following message: \n\n" . $message;    $message2 = "Copy of the message: " . $message;    $headers = "From: " .$email;    $headers2= "From: " . $to;    mail($to,$subject,$message,$headers);    mail($email,$subject2,$message2,$headers2);}echo "Email sent! Thank you " . $firstname . ", We will contact you shortly.";
查看完整描述

2 回答

?
翻翻過去那場(chǎng)雪

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

正如@BlackXero 所提到的,您正在進(jìn)行以下檢查:

if (isset($_POST['submit']))

這通常在您直接從 html 或 php 向 Sendmail.php 提交表單時(shí)使用。所以在這種情況下你不需要那個(gè)檢查。

同樣在此示例中,由于您為表單添加了方法和操作屬性,您的表單仍在嘗試提交某處。在這種情況下,您可以(可能應(yīng)該)刪除它們并將e.preventDefault()加到按鈕單擊功能的開頭。


查看完整回答
反對(duì) 回復(fù) 2021-10-22
?
瀟湘沐

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

您不需要包含這個(gè) require 'Sendmail.php',因?yàn)楸韱问鞘褂?ajax 提交的。并在 if 條件下寫下您的消息,即“電子郵件發(fā)送”


查看完整回答
反對(duì) 回復(fù) 2021-10-22
  • 2 回答
  • 0 關(guān)注
  • 145 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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