Hi,
I need to pass some php global variables from one file to another, but I don't want to use the regular method of file.php?&var1&var2 because the variables should stay hidden!
Is there any way to do this?
I've tried the following code but it doesn't "remember" the global variables. It should switch the $GLOBALS["action"] variable from on to off when reloading the page. It doesn't do that however:
<?php
// If not set, set to "on"
if(!isset($GLOBALS["action"])) {
$GLOBALS["action"] = "on";
}
// Print the current status of action
echo "before: ".$GLOBALS["action"]."<br>";
// Based on the current value switch the variable from off to on or from on to off
if($GLOBALS["action"] != "off") {
$GLOBALS["action"] = "off";
} else {
$GLOBALS["action"] = "on";
}
// Print the current status of action
echo "after: ".$GLOBALS["action"]."<br><br>";
// Reload page link
echo "<a href=".$_SERVER['PHP_SELF'].">reload</a>";
?>
I probably shouldn't be using $GLOBALS but some other variable array which can remember variables??
Thanks,
betonboor