Previous Thread
Next Thread
Print Thread
Rate Thread
domino #271602 03/29/2004 12:16 AM
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
Are you trying to reference these form vars from within a function? If so then, from that point it depends on how you're trying to reference them. Shooting in the dark here, but there could be a variety of scenarios.

Scenario 1
You program with register_globals on. Which means if you have a form variabled named "bar" then you just directly reference it with $bar in your script. If you try to do this inside a function it won't work due to scope. So you'd need to globalize it, like below.

Code
<br />function foo() {<br />   global $bar;<br />   echo $bar;<br />}<br />


Scenario 2
You program with register globals off. Which means you might reference your form variables by using the $HTTP_POST_VARS and $HTTP_GET_VARS arrays. For this to work, you need to globalize those arrays as well to get access to your form vars in your functions.

Code
<br />function foo() {<br />   global $HTTP_POST_VARS,$HTTP_GET_VARS;<br />   echo $HTTP_POST_VARS['bar'];<br />}<br />


If it turns out to be a scenario 2 issue, then if your running at least version 4.1 of PHP then you can make it easier on yourself by using the $_POST and $_GET arrays. These are superglobals so you don't need to globalize them to get access to the keys within. So the following would work, just like scenario 2.

Code
<br />function foo() {<br />   echo $_POST['bar'];<br />}<br />


Of course, there could be a scenario 3 in where I totally missed the mark


UBB.threads Developer
Sponsored Links
Entire Thread
Subject Posted By Posted
OOP insanity Ron M 03/29/2004 3:02 AM
Re: OOP insanity Rick 03/29/2004 3:39 AM
Re: OOP insanity Ron M 03/29/2004 3:50 AM
Re: OOP insanity Rick 03/29/2004 8:16 AM
Re: OOP insanity Ron M 03/29/2004 5:03 PM
Re: OOP insanity scroungr 03/29/2004 5:07 PM
Re: OOP insanity Ron M 04/07/2004 3:45 AM
Re: OOP insanity Astaran 04/09/2004 3:42 PM
Re: OOP insanity Ron M 04/09/2004 8:16 PM

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
• Shock Hosting
• Stable Host
• bluehost
• InterServer
Visit us on Facebook
Member Spotlight
AllenAyres
AllenAyres
Texas
Posts: 21,080
Joined: March 2000
Forum Statistics
Forums63
Topics37,583
Posts293,957
Members13,826
Most Online151,614
Nov 14th, 2025
Today's Statistics
Currently Online 1443
Topics Created 0
Posts Made 0
Users Online 0
Birthdays 7
Top Posters
AllenAyres 21,080
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,834
Greg Hard 4,625
Top Posters(30 Days)
isaac 2
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2026 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.1.0
(Snapshot build 20261026)