你好只需要在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.";
如何將數(shù)據(jù)從 jquery 傳遞到 php,以在 gmail 上發(fā)送消息
函數(shù)式編程
2021-10-22 10:17:24