来自表单结果的地名谢谢页面?

时间:2010-10-22 15:38:44

标签: php confirmation

我设计了一个表单,在提交时通过电子邮件发送结果。 PHP脚本将在成功时显示感谢页面。是否可以将“名称”字段放在单独的感谢页面中?

以下是表单的代码:

<?php
$name = $_REQUEST['name'] ;
$carenumber= $_REQUEST['carenumber'] ;
$email = $_REQUEST['email'] ;
$topic = $_REQUEST['topic'] ;
$message = $_REQUEST['message'] ;

$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "\n";
$Body .= "Caregiver Number: ";
$Body .= $carenumber;
$Body .= "\n";
$Body .= "\n";
$Body .= "Email Address: ";
$Body .= $email;
$Body .= "\n";
$Body .= "\n";
$Body .= "Topic: ";
$Body .= $topic;
$Body .= "\n";
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";

mail( "eriksnet@mac.com", "Message From Myorphan.com Contact Page",
$Body, "From: $email" );

header( "Location: http://www.feedmyorphan.com/contact_confirm.htm" );
?>

3 个答案:

答案 0 :(得分:0)

如果我理解正确的话......

...尝试将name字段设置为$ _SESSION变量,并在感谢页面上通过$ _SESSION访问它。

答案 1 :(得分:0)

您需要将感谢页面设为PHP页面(使用.php扩展名),然后,在您提供的此代码示例的标题中,放置:

header("Location: http://www.feedmyorphan.com/contact_confirm.php?name=" . urlencode($name));

然后,在感谢页面上,在页面的任何位置使用<?php echo $_GET['name'] ?>

答案 2 :(得分:0)

是的,您需要使用SESSIONS并使用PHP将cookie数据发送到第二个脚本。以下是使用cURL的示例。

session_start();
$_SESSION['name'] = $name;   
passSession();

function passSession(){
 $strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
 session_write_close();

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_URL,"http://www.feedmyorphan.com/contact_confirm.php");
 curl_setopt($ch, CURLOPT_COOKIE, $strCookie);
 curl_exec ($ch);
 curl_close ($ch);
}

然后,在第二个脚本中,调用会话并回显会话变量

session_start();
echo $_SESSION['name'];

此外,请务必验证并清理您的输入,以确保提交的数据尽可能准确。