我读过this post(how do i send a variable in the url in javascript),但无法使其正常工作。我必须补充说,我根本不知道JavaScript。我想在PHP中打开一个新的“打印机友好”的页面,但为了我需要的URL发送用户ID,我的代码看起来是这样的:通过url在url中发送php变量值
第1页
<?php
session_start();
$userid = $_SESSION['userid'];
?>
<head>
<script type="text/javascript">
function open_win()
{
window.open("http://www.mysite.com/exams/print.php?uid_print=$userid",'','width=200,height=100')
}
</script>
</head>
<?php
if ($_SESSION['auth']) {
include 'datalogin.php';
echo "<input type='button' value='Print this page' onclick='open_win()' />";
第二页(print.php)
<?php
session_start();
include 'datalogin.php';
$uid_print1 = $_GET['uid_print'];
echo $uid_print1;
但我的输出继电器是:$用户ID