php重定向页面回显提交结果

php redirect page echo submitted results

我希望提交的表单数据显示在重定向页面上,并通过电子邮件发送给用户和我自己。我已经让电子邮件部分开始工作,现在我正在尝试找出重定向到单独页面并显示提交内容的最佳方法。

       <?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;

?>

感谢您的任何建议。

我假设您在此处 post 编写的代码实际上是 post 操作形式,类似于 send.php.

您已经处理了电子邮件正文并且已经让电子邮件正常工作。事实上,"display"提交内容最简单的方法是添加:

echo $body;

我认为这不是您要查找的内容,您想要重定向。我认为您不知道您也可以在此文件中显示信息,它不需要单独的文件来处理 post 表单。通过将 HTML 添加到此文件,您可以向他们显示提交的信息 like this.

如果您真的需要重定向,您将不得不 save the data in a session, or redirect with the data saved in the GET parameters,尽管我认为这两种做法都不是好的做法。

最后一个提示:validate your submitted form 在对其进行任何操作之前。无效的电子邮件地址很可能会使您的 PHP 脚本崩溃。