我正在尝试在 iFrame 中创建一个联系表单。
表单首先在 iFrame 中加载,我使用 method="POST" 目标作为下一个发送邮件的 php 页面。当我尝试回显它们时,我无法在目标页面中检索会话变量。
我查看了其他论坛主题并尝试在两个页面中验证会话 ID,它们是相同的。
请帮忙!
编辑:添加代码。我有 2 个 PHP 文件:
1.联系方式.php
<?php
session_start();
echo "Session ID: ".session_id();
$_SESSION['sesssubject'] = $subject;
$_SESSION['sessmessage'] = $message;
$_SESSION['sessname'] = $name;
$_SESSION['sessemail'] = $email
?>
<table width="400" border="0" align="center" cellpadding="3" cellspacing="1">
<tr>
<td><strong>Contact Form</strong></td>
</tr>
</table>
<table width="400" border="0" align="center" cellpadding="0" cellspacing="1">
<tr>
<td>
<form method="post" action="send_contact.php">
<table width="100%" border="0" cellspacing="1" cellpadding="3">
<tr>
<td width="16%">Subject</td>
<td width="02%">:</td>
<td width="82%"><input name="subject" type="text" id="subject" size="50"></td>
</tr>
<tr>
<td>Message</td>
<td>:</td>
<td><textarea name="message" cols="50" rows="4" id="message"></textarea></td>
</tr>
<tr>
<td>Name</td>
<td>:</td>
<td><input name="name" type="text" id="name" size="50"></td>
</tr>
<tr>
<td>Email</td>
<td>:</td>
<td><input name="email" type="text" id="email" size="50"></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
2.send_contact.php
<?php
session_start();
echo "Session ID: ".session_id();
$subject = $_POST['sesssubject'];
$message = $_POST['sessmessage'];
$name = $_POST['sessname'];
$email = $_POST['sessemail'];
echo "hi";
echo $subject;
echo $message;
echo $name;
echo $email;
$to ='<my-email>';
$send_contact=mail($to,$subject,$message,$name);
if($send_contact)
{
echo "We've received your contact information";
}
else
{
echo "ERROR";
}
?>