开发者

How to pass Post (variable) info to a second page

I have an HTML order form that collects info and then on submission passes that to a PHP form which sends an email. Then I have the PHP form forwarding to a PHP confirmation page.

  • I am using the POST method on my HTML form.
  • I am forwarding to the PHP confirmation page开发者_StackOverflow with header() after it sends the email.

Everything is working fine, but I need to know how to pass the variables along to the confirmation page. I can use them on the email page, but they are dropped on the page forwarding. I'm sure it's easy, but I have a lot to learn yet. :-) Do I have to create a file to store the variables, or can I pass them along?

I know I could display the confirmation page with the PHP page that sends the email (I did have it setup that way) but we have had users bookmark that page which will resend the order every time they visit that bookmark. So I'm separating the pages so if they bookmark the confirmation page it will at least not resend an order.

Make sense? Thanks for your help!


You can keep the parameter sent in POST in session variables. This way on your second page, you can still access them.

For example on your first page :

<?php
session_start();

// ... //

$_SESSION['value1'] = $_POST['value1'];
$_SESSION['value2'] = $_POST['value2'];

header('Location: youremailpage.php');
die();

// ... //
?>

And on your second page :

<?php
session_start();

// ... //

$value1 = $_SESSION['value1'];
$value2 = $_SESSION['value2'];

// ... //
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜