我想你在找什麼是使用隱藏的輸入,讓您的變量從一個頁面傳遞到頁面。
使用類似這樣的形式:
<form method='get'>
<input type='hidden' name='client' value='1'>
// Your other inputs
</form>
這樣,當你得到一個輸入,你可以使用一些簡單的PHP代碼保持從頁傳遞到頁把它撿起來從URL和顯示器它再次根據需要。
編輯:(進一步說明)
當你通過URL從一個網頁傳遞到另一個數據可以用一些簡單的PHP代碼,看看是否有存在進一步把它傳遞 - 這樣的:
<?php //page1.php
if(isset($_GET['user']))
{
$user=htmlspecialchars($_GET['user']);
}
if(isset($_GET['photo']))
{
$photo=htmlspecialchars($_GET['photo']);
}
// Check for anything else you want as needed.
?>
那麼,究竟讓你的鏈接時,你可以這樣做:
<?php
$baseAddress="<a href='thePageIwant.php?thisVar=3";
if(isset($user))
{
$baseAddress.="&user=".$user;
}
if(isset($photo))
{
$baseAddress.="&photo=".$photo;
}
// Add any other variables as needed
$baseAddress.="'>
?>
在網頁的HTML輸出部分,你可以使用這個:
<p>Some text and then a link <?php echo $baseAddress;?>Your Link Text</a></p>
而且您的鏈接將與其他所有通過URL傳遞的變量一起出現。在這種情況下,如果用戶被傳遞到頁面ID爲4,和照片傳遞到頁面ID爲6,HTML輸出將是:
<p>Some text and then a link <a href='thePageIwant.php?thisVar=3&user=4&photo=6'>Your Link Text</a></p>
如果只有用戶是在URL過去了,沒有photo=6
輸出會是這樣的:
<p>Some text and then a link <a href='thePageIwant.php?thisVar=3&user=4'>Your Link Text</a></p>
我不知道你在問什麼。 – David 2012-07-28 02:06:03
你在問如何通過URL傳遞參數嗎? – dykeag 2012-07-28 02:09:33
嗨,對不起,我剛剛看到如何接受awirs:s – user1148875 2012-07-28 02:14:46