风格化一个PHP“;“谢谢你”;消息,使其显示在同一页的底部
当用户在同一页面上提交电子邮件时,我一直在尝试设置一条“谢谢”的样式,以便消息以我选择的颜色显示在提交表单下方风格化一个PHP“;“谢谢你”;消息,使其显示在同一页的底部,php,html,forms,echo,phpmailer,Php,Html,Forms,Echo,Phpmailer,当用户在同一页面上提交电子邮件时,我一直在尝试设置一条“谢谢”的样式,以便消息以我选择的颜色显示在提交表单下方 $email = $_REQUEST['email'] ; require("C:/inetpub/folder/PHPMailer/PHPMailerAutoload.php"); $mail = new PHPMailer(); $mail->IsSMTP(); $mail->Host = "smtp.comcast.net"; $mail->SMTPAu
$email = $_REQUEST['email'] ;
require("C:/inetpub/folder/PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.comcast.net";
$mail->SMTPAuth = true;
$mail->Username = "username@comcast.net"; // SMTP username
$mail->Password = "**********"; // SMTP password
$mail->SMTPSecure = 'TLS';// Enable TLS encryption, `ssl` also accepted
$mail->Port = 25;
$mail->From = $email;
$mail->setFrom('$email', 'Guest');
$mail->addAddress('admin@mydomain.com', 'Support');
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "A new member wishes to be added";
$mail->Body = $email;
$mail->AltBody = $email;
$mail2 = new PHPMailer();
$mail2->IsSMTP();
$mail2->Host = "smtp.comcast.net";
$mail2->SMTPAuth = true;
$mail2->Username = "username@comcast.net"; // SMTP username
$mail2->Password = "*********"; // SMTP password
$mail2->SMTPSecure = 'TLS';
$mail2->Port = 25;
$mail2->setFrom('support@mydomain.com', 'Support');
$mail2->AddAddress("$email");
$mail2->addReplyTo('support@mydomain.com');
$mail2->WordWrap = 50;
mail($to, $subject, $message, $headers);
$mail2->Subject = "Thanks for signing up";
$headers = "From: " . strip_tags($_POST['admin@mydomain.com']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['loo@mydomain.com']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$mail2->IsHTML(true);
$message .= '<p style="font-size:16px; color:#000; font-weight:bold;">Welcome,</p> ';
$message .= "<p style='line-height:1.6; color:#666; font-size:16px;'>You have been added to.</p> " ;
$message .= "</body></html>";
$mail2->Body = $message;
$mail2->AltBody = $message;
if (!$mail2->Send()) {
$feedback = 'Thanks for the email';
}
if (!$mail->Send()) {
$feedback = 'Thanks for the email';
}
?>
然而,到目前为止,我的代码只提交了一封没有感谢的电子邮件
消息,它似乎不回显带有反馈id的p标记
那么,我如何修改代码,使id为#反馈的p标签在提交电子邮件时显示为感谢信息?
$email = $_REQUEST['email'] ;
require("C:/inetpub/folder/PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.comcast.net";
$mail->SMTPAuth = true;
$mail->Username = "username@comcast.net"; // SMTP username
$mail->Password = "**********"; // SMTP password
$mail->SMTPSecure = 'TLS';// Enable TLS encryption, `ssl` also accepted
$mail->Port = 25;
$mail->From = $email;
$mail->setFrom('$email', 'Guest');
$mail->addAddress('admin@mydomain.com', 'Support');
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "A new member wishes to be added";
$mail->Body = $email;
$mail->AltBody = $email;
$mail2 = new PHPMailer();
$mail2->IsSMTP();
$mail2->Host = "smtp.comcast.net";
$mail2->SMTPAuth = true;
$mail2->Username = "username@comcast.net"; // SMTP username
$mail2->Password = "*********"; // SMTP password
$mail2->SMTPSecure = 'TLS';
$mail2->Port = 25;
$mail2->setFrom('support@mydomain.com', 'Support');
$mail2->AddAddress("$email");
$mail2->addReplyTo('support@mydomain.com');
$mail2->WordWrap = 50;
mail($to, $subject, $message, $headers);
$mail2->Subject = "Thanks for signing up";
$headers = "From: " . strip_tags($_POST['admin@mydomain.com']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['loo@mydomain.com']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$mail2->IsHTML(true);
$message .= '<p style="font-size:16px; color:#000; font-weight:bold;">Welcome,</p> ';
$message .= "<p style='line-height:1.6; color:#666; font-size:16px;'>You have been added to.</p> " ;
$message .= "</body></html>";
$mail2->Body = $message;
$mail2->AltBody = $message;
if (!$mail2->Send()) {
$feedback = 'Thanks for the email';
}
if (!$mail->Send()) {
$feedback = 'Thanks for the email';
}
?>
$email=$\u请求['email'];
要求(“C:/inetpub/folder/PHPMailer/phpmailerautoad.php”);
$mail=new PHPMailer();
$mail->IsSMTP();
$mail->Host=“smtp.comcast.net”;
$mail->SMTPAuth=true;
$mail->Username=”username@comcast.net"; // SMTP用户名
$mail->Password=“**********”;//SMTP密码
$mail->SMTPSecure='TLS';//启用TLS加密,也接受'ssl'
$mail->Port=25;
$mail->From=$email;
$mail->setFrom('$email','Guest');
$mail->addAddress('admin@mydomain.com","支持",;
$mail->WordWrap=50;
$mail->IsHTML(true);
$mail->Subject=“希望添加新成员”;
$mail->Body=$email;
$mail->AltBody=$email;
$mail2=新的PHPMailer();
$mail2->IsSMTP();
$mail2->Host=“smtp.comcast.net”;
$mail2->SMTPAuth=true;
$mail2->Username=”username@comcast.net"; // SMTP用户名
$mail2->Password=“**********”;//SMTP密码
$mail2->SMTPSecure='TLS';
$mail2->Port=25;
$mail2->setFrom('support@mydomain.com","支持",;
$mail2->AddAddress($email”);
$mail2->addReplyTo('support@mydomain.com');
$mail2->WordWrap=50;
邮件($to、$subject、$message、$headers);
$mail2->Subject=“感谢您的注册”;
$headers=“From:”。带标签($\u POST['admin@mydomain.com']) . “\r\n”;
$headers.=“回复:”。带标签($\u POST['loo@mydomain.com']) . “\r\n”;
$headers.=“MIME版本:1.0\r\n”;
$headers.=“内容类型:text/html;字符集=ISO-8859-1\r\n”;
$message='';
$mail2->IsHTML(true);
$message.='欢迎光临,
;
$message.=“您已添加到中。
”;
$message.=“”;
$mail2->Body=$message;
$mail2->AltBody=$message;
如果(!$mail2->Send()){
$feedback='谢谢你的邮件';
}
如果(!$mail->Send()){
$feedback='谢谢你的邮件';
}
?>
html:
$email = $_REQUEST['email'] ;
require("C:/inetpub/folder/PHPMailer/PHPMailerAutoload.php");
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = "smtp.comcast.net";
$mail->SMTPAuth = true;
$mail->Username = "username@comcast.net"; // SMTP username
$mail->Password = "**********"; // SMTP password
$mail->SMTPSecure = 'TLS';// Enable TLS encryption, `ssl` also accepted
$mail->Port = 25;
$mail->From = $email;
$mail->setFrom('$email', 'Guest');
$mail->addAddress('admin@mydomain.com', 'Support');
$mail->WordWrap = 50;
$mail->IsHTML(true);
$mail->Subject = "A new member wishes to be added";
$mail->Body = $email;
$mail->AltBody = $email;
$mail2 = new PHPMailer();
$mail2->IsSMTP();
$mail2->Host = "smtp.comcast.net";
$mail2->SMTPAuth = true;
$mail2->Username = "username@comcast.net"; // SMTP username
$mail2->Password = "*********"; // SMTP password
$mail2->SMTPSecure = 'TLS';
$mail2->Port = 25;
$mail2->setFrom('support@mydomain.com', 'Support');
$mail2->AddAddress("$email");
$mail2->addReplyTo('support@mydomain.com');
$mail2->WordWrap = 50;
mail($to, $subject, $message, $headers);
$mail2->Subject = "Thanks for signing up";
$headers = "From: " . strip_tags($_POST['admin@mydomain.com']) . "\r\n";
$headers .= "Reply-To: ". strip_tags($_POST['loo@mydomain.com']) . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$message = '<html><body>';
$mail2->IsHTML(true);
$message .= '<p style="font-size:16px; color:#000; font-weight:bold;">Welcome,</p> ';
$message .= "<p style='line-height:1.6; color:#666; font-size:16px;'>You have been added to.</p> " ;
$message .= "</body></html>";
$mail2->Body = $message;
$mail2->AltBody = $message;
if (!$mail2->Send()) {
$feedback = 'Thanks for the email';
}
if (!$mail->Send()) {
$feedback = 'Thanks for the email';
}
?>
<div class="guestlist">
<form action="?" method="post">
<input type="email" title="Enter Email Address" class="emailaddress" name="email" placeholder="Enter your Email Address" />
<button class="button" title="Submit Email to Guestlist" name="submit" value="Submit" type='submit'>Join</button>
<p id="feedback"> <?php echo $feedback; ?> </p>
</form>
</div>
</div>
参加
您应该阅读PHP手册,了解如何解释和编译代码以及输出内容
反馈的html
变量为空李>
feedback
变量现在保存一个值,但HTML页面不会重新加载,因此它保持不变反馈
,或者使用ajax并聆听答案:
$("button[name=submit]").on("click",function(){
type: "post",
url: mail.php,
success: function(serverResponse){
$("#feedback").html(serverResponse);
}
});
在这种情况下,您应该
echo$反馈代码>如果电子邮件成功,我不知道如何设置$feedback
if (!$mail2->Send()) {
$feedback = 'Thanks for the email';
}
if (!$mail->Send()) {
$feedback = 'Thanks for the email';
}
对我来说,如果不成功。HTML与php的关系如何?反馈id与php echo feedback命令以及为什么在成功时设置$feedback,而在电子邮件未正确发送时不显示适当的消息。为什么要给它下两次定义呢。哈哈……别开玩笑了。我像几年前一样,根据。我遇到的唯一问题是AIM,因为他们对邮件标题很挑剔,如果你错过了一个EOL字符,你就会被套住,它永远不会通过他们的垃圾邮件过滤器。不过我离题了。如果(!$mail->Send()){echo”消息无法发送,我以前就遇到过这个问题。“echo”邮件错误:“.$mail->ErrorInfo;退出”}无论何时我加载我的网页,我都会收到一条错误消息,而不是我的站点,所以我肯定代码有问题。顺便说一句,我的网页包含PHP和HTML,但保存为.phpWell是的,运行PHP代码应该是.PHP,并且在一个文件中同时包含这两个代码不是问题。使用上面的代码,您的带有Mailer error doe的echo语句这对我来说没什么意义,有出口“可能会导致语法错误,我猜是这样的,并且说exit会停止运行脚本的其余部分,所以我不明白为什么会出现这种情况。在学习和阅读文档时,只需后退一步,深呼吸,重复简单的事情。我不想说得太苛刻,但是有很多文档,你应该把重点放在基本知识上。我更喜欢在不加载另一个html页面或使用ajax的情况下这样做,我遵循了这个示例,但我无法将其集成到我的code@user3771570您需要阅读PHP手册,从最基本的开始。。。然后您可能会理解为什么服务器端的PHP代码不能动态更改页面。