在确认页面上显示表单结果

时间:2014-04-28 19:21:44

标签: php html server-side-includes

我有一个简单的html表单。

<form name="cmxform" method="post" action="projecthandler.php" id="doxform"> 

<tr>

    <td><input name="firstname" type="text" size="40"></font></td>
  </tr>
<tr>

</tr>
<tr>

    <td><input name="lastname" type="text" size="40"></td>
  </tr>
</form>

projecthandler.php scrpit向用户发送电子邮件

<?php

if(isset($_POST['firstname'])) {

   $email_to = "shruti15sargam@gmail.com";
   $email_subject = "Project Subject";
   $email_subject_user = "Confirmation";

    $firstname = $_POST['firstname']; // required

    $lastname = $_POST['lastname']; // required




    $email_message = "Form details below.\n\n";
    $email_message_user = "Thank you....";



    function clean_string($string) {

      $bad = array("content-type","bcc:","to:","cc:","href");

      return str_replace($bad,"",$string);

    }



    $email_message .= "First Name: ".clean_string($firstname)."\n";

    $email_message .= "Last Name: ".clean_string($lastname)."\n";





// create email headers

$headers = 'From: '.$Email."\r\n".

'Reply-To: '.$email_from."\r\n" .

'X-Mailer: PHP/' . phpversion();


mail($Email, $email_subject_user, $email_message, 'From: donotreply@somemail.edu');
header('Location: thanks.html');


?>



 <div>
echo "Hello World";
        </div>
   

最后的thanks.html页面需要在表单数据上显示这些名字和姓氏值。如何将此表单的结果回显到确认(thanks.html)页面。 感谢。

1 个答案:

答案 0 :(得分:1)

您可以在网址www.mydomain.co.uk?value1=val&value2=val2

中发送值

然后从那里获取数据(假设您可以明智地使用此安全性)。或者已经提到过你可以设置会话值:

即:

<?php

session_start();
$_SESSION['value1'] = $val;
$_SESSION['value2'] = $val2;

会议可能是最好的方式。