SOLVED - How can I make a variable useable from card to card
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
SOLVED - How can I make a variable useable from card to card
In the Opencard handler of the login card, I made a variable global (ie. global CurUserID). Login now works fine and I am reading from the database perfectly.
I expected that variable to be useable across other cards, but it was not.
I am looking up a User's ID from the UserValidation table (which I have checked on, and it is reading it properly) and I want that UserID to then carry over to other cards . . . or should I be using $_SESSION instead?
That way I can track the logged in user via his or her UserID.
How is this done?
Mike
I expected that variable to be useable across other cards, but it was not.
I am looking up a User's ID from the UserValidation table (which I have checked on, and it is reading it properly) and I want that UserID to then carry over to other cards . . . or should I be using $_SESSION instead?
That way I can track the logged in user via his or her UserID.
How is this done?
Mike
Last edited by admin12 on Thu Jul 28, 2011 1:28 am, edited 1 time in total.
Re: How can I make a variable useable from card to card
Did you declare the global in the other cards?
Re: How can I make a variable useable from card to card
I have it declared in the opencard of each card.
However, the LOGIN card's SUBMIT button is where the script is for determining the user info. Once I have the UserID, how do I put it in a global variable that can be used on every card in the stack?
Mike
However, the LOGIN card's SUBMIT button is where the script is for determining the user info. Once I have the UserID, how do I put it in a global variable that can be used on every card in the stack?
Mike
Re: How can I make a variable useable from card to card
If you've declared the global in all the scripts you need to access it, then you should be able to do:
put "the new value" into theGlobalVariable
in the Submit button's script, and it will be available in all the places you've declared it.
AFAIK, globals don't inherit, so if you've declared it in the card, and you need it in a button on the card, you need to declare it in the button as well.
put "the new value" into theGlobalVariable
in the Submit button's script, and it will be available in all the places you've declared it.
AFAIK, globals don't inherit, so if you've declared it in the card, and you need it in a button on the card, you need to declare it in the button as well.
-
- Posts: 361
- Joined: Wed Apr 27, 2011 2:12 pm
Re: How can I make a variable useable from card to card
OK. I declared it everywhere.
Global curUserID
So, in this line:
put "the new value" into theGlobalVariable
is curUserID the theGlobalVariable?
Mike
Global curUserID
So, in this line:
put "the new value" into theGlobalVariable
is curUserID the theGlobalVariable?
Mike
Re: How can I make a variable useable from card to card
Got it - I think it's working. I'll have to test it by making a bunch of records.
Mike
Mike
Re: How can I make a variable useable from card to card
Just to be clear, a global needs to be defined in every script where it will be used (not in every handler).
So if you have the global defined at the top of the card script, you don't need to declare it inside all the handlers within the card script. If you need to use the global value in a button's script, define it at the top of the script and it will be available to all the handlers in that button script (eg mouseUp, mouseDown, mouseEnter, etc)
So if you have the global defined at the top of the card script, you don't need to declare it inside all the handlers within the card script. If you need to use the global value in a button's script, define it at the top of the script and it will be available to all the handlers in that button script (eg mouseUp, mouseDown, mouseEnter, etc)
Re: How can I make a variable useable from card to card
Thank you.
I have it at the top of each and every script. It seems to be working well.
Mike
I have it at the top of each and every script. It seems to be working well.
Mike