感谢页面中表格结果中的地点名称?

发布于 2024-09-28 18:50:26 字数 935 浏览 3 评论 0原文

我设计了一个表格,在提交后通过电子邮件发送结果。成功后,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( "[email protected]", "Message From Myorphan.com Contact Page",
$Body, "From: $email" );

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

I designed a form that emails the results when submitted. The PHP script will show a thank you page upon success. Is it possible to place the the "name" field in a separate thank you page?

Here is my code for the form:

<?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( "[email protected]", "Message From Myorphan.com Contact Page",
$Body, "From: $email" );

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

少女净妖师 2024-10-05 18:50:26

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

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

然后,在感谢页面上使用 页面上的任何位置。

You would need to make the thank you page a PHP page (using the .php extension), then, in your header in this code sample you have provided, place:

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

Then, on the thank you page, use <?php echo $_GET['name'] ?> anywhere on the page.

愁以何悠 2024-10-05 18:50:26

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

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

If I understand you correctly...

...try setting the name field as a $_SESSION variable, and accessing it through $_SESSION on the thank you page.

强者自强 2024-10-05 18:50:26

是的,您需要使用 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'];

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

Yes, you need to use SESSIONS and send the cookie data to the second script using PHP. Here is an example using 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);
}

Then, in your second script, call for the session and echo the session variable

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

Also, be sure to validate and sanitize your input to ensure the data being submitted is as accurate as possible.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文