我希望提交显示在重定向页面上的表单数据,并通过电子邮件发送给用户以及我自己。我已经获得了电子邮件部分,现在我正在尝试找出重定向到单独页面并显示提交内容的最佳方式。
<?php
$emailSubject = 'MFPT Submission';
$webMaster = 'todd@treble-one.com';
$Email = $_POST['Email'];
$FirstName = $_REQUEST['FirstName'];
$LastName = $_REQUEST['LastName'];
$organization = $_REQUEST['organization'];
$AddressLine1 = $_REQUEST['AddressLine1'];
$AddressLine2 = $_REQUEST['AddressLine2'];
$City = $_REQUEST['City'];
$StateProvince = $_REQUEST['StateProvince'];
$Country = $_REQUEST['Country'];
$ZipPostalCode = $_REQUEST['ZipPostalCode'];
$Telephone = $_REQUEST['Telephone'];
$Title = $_REQUEST['Title'];
$WrittenPaper = $_REQUEST['WrittenPaper'];
$Suggested_Conference_Session = $_REQUEST['Suggested_Conference_Session'];
$Suggested_Conference_Track_Other = $_REQUEST['Suggested_Conference_Track_Other'];
$CoAuthor = $_REQUEST['CoAuthor'];
$Abstract = $_REQUEST['Abstract'];
$body = <<<EOD
Email: $Email
FirstName: $FirstName
LastName: $LastName
organization: $organization
AddressLine1: $AddressLine1
AddressLine2: $AddressLine2
City: $City
StateProvince: $StateProvince
Country: $Country
ZipPostalCode: $ZipPostalCode
Telephone: $Telephone
Title: $Title
WrittenPaper: $WrittenPaper
Suggested_Conference_Session: $Suggested_Conference_Session
Suggested_Conference_Track_Other: $Suggested_Conference_Track_Other
CoAuthor: $CoAuthor
Abstract: $Abstract
Comments: $Comments
EOD;
$host = "mail.treble-one.com";
$username = "todd@treble-one.com";
$password = "*******";
$headers = 'From: Your name <mfpt@mfpt.com>' . "\r\n";
$headers .= "Content=type: text/html\r\n";
$headers .= "CC: $Email\r\n";
$success = mail ($webMaster, $emailSubject, $body,$headers);
echo $body;
?>
感谢您的任何建议。
答案 0 :(得分:0)
我假设您在此处发布的代码实际上是表单帖子操作,例如send.php
。
您已经处理了电子邮件正文,而且您已经收到了电子邮件。事实上,最简单的方式是显示&#34;提交的内容是通过添加:
echo $body;
我认为这不是您正在寻找的,您想要重定向。我认为你不知道你也可以在这个文件中显示信息,它不需要是一个单独的文件来处理帖子形式。通过向此文件添加HTML,您可以向他们显示已提交的信息like this。
如果您确实需要重定向,则必须save the data in a session或使用data saved in the GET parameters重定向,但我不会称之为良好做法。
最后一个提示:validate your submitted form在做任何事情之前。无效的电子邮件地址很可能会导致PHP脚本崩溃。