PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 



Go Back   Dev Articles Community ForumsProgrammingPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 11th, 2002, 04:52 AM
trinh trinh is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 trinh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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 ?

Reply With Quote
  #2  
Old September 11th, 2002, 09:13 AM
Brian Rosner Brian Rosner is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Location: Denver, CO
Posts: 34 Brian Rosner User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
Send a message via ICQ to Brian Rosner Send a message via AIM to Brian Rosner Send a message via Yahoo to Brian Rosner
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:
<?php
session_start
();
$var "username";
session_register("var");
?>


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.

Reply With Quote
  #3  
Old September 11th, 2002, 09:45 AM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
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:
 session_start();
$_SESSION[myVar] = $_POST[userInput]; 


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.

Reply With Quote
  #4  
Old September 11th, 2002, 11:42 AM
trinh trinh is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 7 trinh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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) ?

Reply With Quote
  #5  
Old September 11th, 2002, 01:43 PM
crazytrain81 crazytrain81 is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 232 crazytrain81 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 16
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingPHP Development > global variable in PHP to store users input ???


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap