-1

所以我似乎无法弄清楚如何在 PHP 标头刷新后传输会话变量,代码如下:基本上我的工作流程是用户将表单提交到一个 php 处理页面,该页面对变量进行处理,完成后我想要表单重定向到“offers.php”,保持会话变量不变。

谢谢您的帮助

php进程页面

    <?php
    session_start();
    session_write_close();
    header('Location: http://www.examplesite.info/offers.php');

    //Get Variables from form
    $_SESSION['name'] = $_POST['name'];
    $_SESSION['zipcode'] = $_POST['zip'];
    $_SESSION['email'] = $_POST['email'];
    $_SESSION['insType'] = $_POST['insOption'];

    ?>

offer.php 页面

    <?php 
    session_start(); 

    $name = $_SESSION['name'];  
    $email = $_SESSION['email'];
    $zip = $_SESSION['zipcode'];
    $ins = $_SESSION['insType'];

?>

4

1 回答 1

0

为什么不在重定向之前放置会话分配

//Get Variables from form
$_SESSION['name'] = $_POST['name'];
$_SESSION['zipcode'] = $_POST['zip'];
$_SESSION['email'] = $_POST['email'];
$_SESSION['insType'] = $_POST['insOption'];

header('Location: http://www.examplesite.info/offers.php');
于 2012-08-24T00:04:56.867 回答