|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
global variable in PHP to store users input ???
My problem is:
- I'd like to create a global variable (in PHP of course) to store the value of a submitted field so that (the global variable) is available to any other users from other clients acess to my site. Its something like "application variable" in ASP, but I wonder how to do it in PHP. Anybody can help me out of this problem ? |
|
#2
|
|||
|
|||
|
I've heard of an Application Variable in ASP, but actually learned what it did. But in PHP you can register a variable to a session for access by the server as the user browses your website. To do so:
PHP Code:
That will register the $var variable to the session and whatever page that has session_start() will make that variable available. Use $_SESSION["var"]; to retreive it. This may not help, but maybe. ![]() |
|
#3
|
|||
|
|||
|
session variables
If "register globals" is set to "off", you don't have to explicitly register session variables with session_register(), you can simply use the superglobal $_SESSION array.
PHP Code:
Remember you have to put session_start() at the start of each page that you intend to access session variables from. It will not do anything if there is still an active session, but if the user has timed out the session it will load the most recent session for that user. Either way the end result is being able to access $_SESSION vars across your pages. |
|
#4
|
|||
|
|||
|
I dont think session variable is the solution for this problem.
Because session variable is available only for each user who access the site (it persists across the pages of the site for this user) but there's no way to make a session variabe of a user available for another user from another client. For example after a user submits his input, how to write PHP code so that the input can be retrieved by other users on other clients (of course without using database) ? |
|
#5
|
|||
|
|||
|
well..
you can do it using flat files, but, since php runs a different isntance of each script for each user (it would be worthless if it didn't), user A can't access user B's $_REQUEST variables, it just doesn't work that way.
what are you trying to achieve like this? i can't see why one would want this feature unless you're doing some sort of chat client, on which there is an article here on devarticles.com. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > global variable in PHP to store users input ??? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|