2

这是我的代码:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$subject = $_POST['subject'];
$message = $_POST['message'];
$formcontent = "From: $name \n Email: $email \n Subject: $subject \n Message: $message";
$recipient = "hunter@dreaminginhd.com";
$subject = "Contact Form";
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
?>

我只需要知道如何在单击提交后重定向到 HTML 页面并确保脚本发送电子邮件。任何帮助将不胜感激!

4

4 回答 4

2

将此添加到脚本的末尾:

header("Location: URL");

URL您要重定向到的页面的 URL 在哪里。

于 2013-10-11T19:53:46.353 回答
0

您可能缺少打开表单和关闭表单,或者您只是将其包含在内

 <form name="PL" action="newForm.php" method="post">
 <?php
 $name = $_POST['name'];  
 $email = $_POST['email'];

 $subject = $_POST['subject'];

 $message = $_POST['message'];

 $formcontent = "From: $name \n Email: $email \n Subject: $subject \n Message:   
 $message";

 $recipient = "hunter@dreaminginhd.com";

 $subject = "Contact Form";

 $mailheader = "From: $email \r\n";

 mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");  
include "newForm2.php";
 ?>
 <input type="submit" name="btn_submit" value="Display Invoice" /> 
 </form>
于 2013-10-11T20:41:20.813 回答
0

php

header('Location: login.php?msg=1');

javascript

<script> window.location='forgot.php'</script>";

html

<META HTTP-EQUIV="REFRESH" CONTENT="3;URL=http://google.com">
于 2013-10-11T20:00:47.530 回答
0

首先,我们让 mailto 函数与 localhost 和电子邮件客户端一起使用:
检查 stackoverflow 上的此链接:
URL 链接:通过收集用户通过表单提供的信息向所有者发送电子邮件?

然后我推荐使用 Swiftmailer。http://swiftmailer.org/docs/sending.html他们得到了最好的手册。

于 2013-11-29T06:17:35.403 回答