2015-01-10 35 views
0

我试图从一个PHP文件发送一个变量名为“主题”的值到另一个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 


?> 
+0

题外话,但你最后的'$ headers'变量应该是'$头。='(串联),而不是'$标题=' –

回答

2

看起来你是在第二个文件中使用$_GET代替$_SESSION

变化

$topic = $_GET['top']; 

$topic = $_SESSION['top']; 
+0

谢谢你...我编辑我的代码,但它仍然不工作 – 654

+0

你拼写正确吗? –

+0

在你发送任何输出之前,你正在调用'session_start()'*吗? –

相关问题