Hi Joeore,
The problem relates wholly to register_globals.
First some URLs for you to reference:
Why session_register() is bad:
http://p2p.wrox.com/topic.asp?TOPIC_ID=2052
Nik's FAQ:
http://p2p.wrox.com/archive/beginnin...2002-11/17.asp
And here's a long thread that contains many more urls to reference on both php.net on the wrox forums:
http://p2p.wrox.com/topic.asp?TOPIC_ID=4017
Code:
<?php
# Instead of session_register, use the $_SESSION[] superglobal
# If $_SESSION["..."] is not set, then create it.
if (!isset($_SESSION["guarda1contatore"])) {$_SESSION["guarda1contatore"] = 0;}
if (!isset($_SESSION["guarda2contatore"])) {$_SESSION["guarda2contatore"] = 0;}
if (!isset($_SESSION["guarda3contatore"])) {$_SESSION["guarda3contatore"] = 0;}
if (!isset($_SESSION["guarda4contatore"])) {$_SESSION["guarda4contatore"] = 0;}
echo "<html><head><title></title></head><body>";
# pagina is part of a URL query string and thus accessible via the $_GET superglobal
if (isset($_GET["pagina"])) {
echo "<span style='font-weight: bold;'>ora sei alla pagina {$_GET["pagina"]}</span><br /><br />";
$_SESSION["guarda{$_GET["pagina"]}contatore"]++;
}
for ($i = 1; $i <= 4; $i++) {
if ($_GET["pagina"] == $i) {
# Use $_SERVER["PHP_SELF"] instead of $PHP_SELF
echo "<span style='font-weight: bold;'><a href=\"{$_SERVER["PHP_SELF"]}?" . SID . "pagina=$i\">pagina $i</a></span>";
} else {
echo "<a href=\"{$_SERVER["PHP_SELF"]}?" . SID . "pagina=$i\">pagina $i</a>";
}
echo " : totale visite" . $_SESSION["guarda${i}contatore"] . "<br />";
}
echo "</body></html>";
?>
I also have a nifty HTML standards compliance FAQ:
http://p2p.wrox.com/topic.asp?TOPIC_ID=4028
Test that out and see what it does. I haven't tested for parse errors.
: )
Rich
:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::