我正在尝试将名为"topic"的变量的值从一个 php 文件发送到另一个 php 文件......代码中没有错误,但变量的值未显示在其他 PHP 文件中......请帮忙...谢谢
<?php
$name = $_POST['name'];
$to = $_POST['to'];
$from = $_POST['from'];
$subject = $_POST['subject'];
$topic = $_POST['topic'];
$message = "From: ".$name."rn";
$message .= $_POST['message'];
$headers .= "MIME-Version: 1.0rn";
$headers .= "Content-type: text/htmlrn";
$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
?>
看起来您在第二个文件中使用的是$_GET
而不是$_SESSION
。
改变
$topic = $_GET['top'];
自
$topic = $_SESSION['top'];