0

我认为问题不在于邮件功能代码,而在于我对 $_SESSION 变量的方法。我有一个由 5 页组成的表单,第五个是预览页。最终提交后,在预览页面上,我希望将整个 $_SESSION 数据发送到两个不同的电子邮件地址。

我在预览页面上显示数据如下:

<?php
//retrieve session data
echo "<b>&nbsp;&nbsp;Varname: </b>". $_SESSION['varname'];
?>

以 method="post" 和 action="mail.php" 的形式。

在 mail.php 中,我开始会话,然后:

    $_SESSION['email'] = $mail;
        $_SESSION['varname'] = $varname;

        $email_from = 'mail@company.de';

        $email_subject = "Mail";

        $email_body = "You have submitted the following data: $inhalt.\n";

        $to = "mymail@company.de, $mail";

        $headers = "From: Company";




        mail($to,$email_subject,$email_body,$headers); 

提交表单后,页面变为空白。我到底做错了什么?

4

1 回答 1

0

我最终设法解决了这个问题,如下:

   $email_from = 'mail@company.de';

   $email_subject = "Mail"; 

   $to = ("myadress@work.de," . $_SESSION['email'] . "");
        mail($to,"Form submission","Form data:

    Inhalt: " . $_SESSION['inhalt1'] . " 

    "); 

正如我在问题中所说,问题在于我对$_SESSION变量的方法。而不是$_SESSION['varname'] = $varname,我只是直接用. $_SESSION['varname'] .'。

于 2012-07-16T14:44:35.200 回答