会话未从一个 PHP 值获取到另一个 PHP 值的值


session not getting value from one php value to another

我正在尝试将名为"topic"的变量的值从一个 php 文件发送到另一个 php 文件......代码中没有错误,但变量的值未显示在其他 PHP 文件中......请帮忙...谢谢

<?php
$name = $_POST['name'];
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$topic = $_POST['topic'];
$message = "From: ".$name."'r'n";
$message .= $_POST['message'];
$headers .= "MIME-Version: 1.0'r'n";
$headers .= "Content-type: text/html'r'n";
$headers = "From:" . $from;

 session_start();
 $_SESSION['top'] = $topic;
 mail($to,$subject,$message,$headers);
?> 

另一个 PHP 文件是

  <?php 
  session_start();
 $topic = $_GET['top'];
 ?> 
   <h1><center>Meeting Invitation</center></h1>
   <form action="my.php" method="post">
      You are invited for the meeting on <?php echo $topic;?>
       proposed dates are :<br><br>
        Date &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Time<br>

        10 jan,2015 &nbsp; &nbsp; &nbsp; 10.00 am<input type = "radio" name = "dat" <?php if 
    (isset($dat) && $dat=="val1") echo "checked";?> value = "val1" checked="true" ><br>
        12 feb,2015 &nbsp; &nbsp; &nbsp; 12.15 am<input type = "radio" name = "dat" <?php if 
   (isset($dat) && $dat=="val2") echo "checked";?> value = "val2" ><br><br>
        Proposed locations are :<br>
        Location 1 : &nbsp; &nbsp; &nbsp; Islamabad <input type = "radio" name = "location" <?php 
  if (isset($location) && $location=="val1") echo "checked";?>  value = "val1" checked="true" >               
 <br>
    Location 2 : &nbsp; &nbsp; &nbsp; Rawalpindi <input type = "radio" name = "location" <?php if      
   (isset($location) && $location=="val2") echo "checked";?>  value = "val2" ><br><br>
    Do you want travel facility ? &nbsp; &nbsp; &nbsp;
     <input type="checkbox" name="check_list1" value="yes"> <br><br>
    Do you want hotel facility ? &nbsp; &nbsp; &nbsp;
        <input type="checkbox" name="check_list2" value="yes"> <br><br><br>
        <input type="submit" name="send" value="Send Response">
        <input type="reset" >
   </form>
<?php 

 ?>

看起来您在第二个文件中使用的是$_GET而不是$_SESSION

改变

$topic = $_GET['top'];

$topic = $_SESSION['top'];