我一直在阅读有关此的相关帖子,但我仍然没有得到正确的答案。我采纳了他们的建议,但未能实现我想要的。我想实现这一点:当我单击提交按钮时,我希望将 $_SESSION['roomno'] = 400 和 $_SESSION['chairnum']=5 传递到 PHP 中的另一个页面。
部分 monica.php 代码:
<div id="popupContact">
<a id="popupContactClose">x</a>
<center><form method = "POST" action="gervent.php">
<h1>Information </h1>
Fullname : <input type="text" name="student_name" /><br /><br />
Student ID No. : <input type="text" name="stud_id" />
<br /><br />
<input type="submit" value="Submit" onclick=???/>
</form></center>
</div>
<div id="backgroundPopup"></div>
gervent.php
<?php
session_start();
$name = $_POST['student_name'];
$stud_id = $_POST['stud_id'];
/*Should have this
$room_id = $_SESSION['roomno'];
$chair_num = $_SESSION['chairnum'];
*/
mysql_connect("localhost", "root", "") or die (mysql_error());
mysql_select_db('seat_reservation') or die (mysql_error());
$query = mysql_query("INSERT INTO reservation WHERE (room_id, chair_number, chair_status, student_name, stud_id) VALUES ($room_id, $chair_num, 1, $name, $stud_id)");
if($insert)
die ("Seat reserved! <br />Redirecting...<meta http-equiv='refresh' content=2;monica.php>");
else
die ("Try Again! <br />Redirecting...<meta http-equiv='refresh' content=2;monica.php>");
?>
所以 gervent.php 应该从 monica.php 获取 SESSION 值,以便它可以在插入时使用它。在点击中怎么可能?注意:简单解释一下,我对 PHP 快车道来说太慢了。谢谢!