会话没有从一个php值到另一个值获取值

时间:2015-01-10 17:45:49

标签: php session

我正在尝试发送名为" 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 


 ?>

1 个答案:

答案 0 :(得分:2)

您似乎在第二个文件中使用$_GET而不是$_SESSION

更改

$topic = $_GET['top'];

$topic = $_SESSION['top'];