|
Posted by rithish on 12/27/05 19:36
Is it possible to set a custom server variable so that it may be used
in the latter part of a script? Say something like $_SERVER["myvar"] =
"myvalue", and then be able to use 'myvar' later.
The reason being that I want some client-side information to flow to
PHP, and the PHP script flow will be controlled depending on this
information.
[snippet]
<?php
if ($_REQUEST["action"] == "setvar")
{
$_SERVER["WindowName"] == $_REQUEST["window"];
exit ();
}
?>
<HTML>
<HEAD>
<SCRIPT TYPE="TEXT/JAVASCRIPT">
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var request =
"http://saraswati.tallysolutions.com/tallyweb/test/TestRithishGeneric.php?action=setvar&window="+window.name;
xmlhttp.open("POST", request, false);
xmlhttp.send();
response = xmlhttp.responseText;
</SCRIPT>
</HEAD>
<BODY>
<?php
if ($_SERVER["WindowName"] == "x") { ... do this ... }
else { ... do that ... }
?>
</BODY>
</HTML>
[/snippet]
Basically, the execution flows depending on which window the file is
being invoked in. I guess I could use sessions for this. However, I
wanted to know if there were any alternative to sessions. Setting &
Getting a server variable would be that much more simple.
And before I am flamed, the app is being developed for our intranet,
and hence you see the usage of ActiveXObject("Microsoft.XMLHTTP")
Suggestions / comments / even flamings solicited.
Regards,
Rithish.
Navigation:
[Reply to this message]
|