Okay the following script shows $site variable is transferred via QUERY_STRING and it works:
----------------------------test1.php--------------
<? {
global $PHP_SELF;
if(empty($site))
$site="My site";
print("<H1>Welocme To $site</H1><p>Select the sites below<p>");
print("<a href=$PHP_SELF?site=Google>Google</a><br>
<a href=$PHP_SELF?site=AOL>AOL</a><br>
<a href=$PHP_SELF?site=Yahoo>Yahoo</a><br>");
print("<form action=$PHP_SELF?><input type=Submit value=Other sites></form>");
}
?>
Later I have turned the previous script into a function, I get stucked when I reached this point:
----------------------------test2.php-----------------------
<? function showsites(){
global $PHP_SELF;
if(empty($site))
$site="My site";
print("<H1>Welocme To $site</H1><p>");
print("Select the sites below<p>");
print("<a href=$PHP_SELF?site=Google>Google</a><br>
<a href=$PHP_SELF?site=AOL>AOL</a><br>
<a href=$PHP_SELF?site=Yahoo>Yahoo</a><br>");
print("<form action=$PHP_SELF?><input type=Submit value=Other sites></form>");
}
?>
<? function others(){
print("<H1>OTHER SITES</H1>");
//data goes here
}
?>
<? {
if(!$submit)
showsites();
else
other();}
?>
My question is: Is there any solution for test2.php? Or how to transfer variables via QUERY_STRING to a function?
I hope anyone could help me to figure out test2.php. Thank you.