我讀過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