我正在尝试发送名为" 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 Time<br>
10 jan,2015 10.00 am<input type = "radio" name = "dat" <?php if
(isset($dat) && $dat=="val1") echo "checked";?> value = "val1" checked="true" ><br>
12 feb,2015 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 : Islamabad <input type = "radio" name = "location" <?php
if (isset($location) && $location=="val1") echo "checked";?> value = "val1" checked="true" >
<br>
Location 2 : Rawalpindi <input type = "radio" name = "location" <?php if
(isset($location) && $location=="val2") echo "checked";?> value = "val2" ><br><br>
Do you want travel facility ?
<input type="checkbox" name="check_list1" value="yes"> <br><br>
Do you want hotel facility ?
<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 :(得分:2)
您似乎在第二个文件中使用$_GET
而不是$_SESSION
。
更改
$topic = $_GET['top'];
到
$topic = $_SESSION['top'];