|
Posted by Gordon Burditt on 12/28/05 07:00
>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.
You can't make changes to $_SERVER and have them stick in subsequent
invocations of PHP. And even if you could, you wouldn't want to,
especially for this application.
>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.
You want client-side information to flow from MY browser to PHP,
and from there control the script flow for ME, YOU, THE POPE, and
PRESIDENT BUSH? In the current political environment, that may
make you guilty of treason. I hope this information does not contain
credit card numbers or nuclear launch codes.
><?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.
No, setting and getting a server variable would be really, really
messy. Have you ever thought about what a grocery store would be
like if each store had exactly ONE cart, and all customers had to
share it? Oh, yes, your customers DON'T have unique identification,
like driver's license numbers, names, IP address, or whatever.
How do you propose for this to work when you've got 500 simultaneous
users? (Sessions are a good way of letting each user have his
own set of variables.)
Variables passed in a URL as you show above show up in $_GET or
$_POST (and $_REQUEST). It seems like you are using the variable
in the same page fetch as retrieving it, in which case why bother
with "server variables"?
>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.
Gordon L. Burditt
Navigation:
[Reply to this message]
|