Page 1 of 1

remembering a passed through variable

Posted: Sat Aug 17, 2002 3:13 am
by -[Bl@de Runner]-
Hi guys,

I pass, with the URL, a variable through to a page in my site.
Let's call the variable 'index'.

In that page a submit happens when you press a button.
And then, when you press that button, I want to use that variable, but at that point the variable is 0.

How can I store this variable somewhere so that when I press the submit button, it still knows the value of the variable ?

Posted: Sat Aug 17, 2002 4:44 am
by Jay
Store it as a cookie or session value, or if you've got a form that you're using, store it as a hidden field in that form!

Posted: Sat Aug 17, 2002 5:13 am
by -[Bl@de Runner]-
Like this ?

<input name="forumIndex" type="hidden" value="$fIndex">

Cause when I type this:

echo "$forumIndex";

It gives me the following result: $fIndex which is wrong

Posted: Sat Aug 17, 2002 5:22 am
by -[Bl@de Runner]-
its ok, i got it :-)


i did it with : value="<?php echo "$fIndex"; ?>"

Posted: Sat Aug 17, 2002 11:13 am
by Jay
-[Bl@de Runner]- wrote:its ok, i got it :-)
i did it with : value="<?php echo "$fIndex"; ?>"

You could just do value="<?=$fIndex?>"

Posted: Sat Aug 17, 2002 11:59 am
by WiZARD
Jay wrote:[quote="-[Bl@de Runner]-"]its ok, i got it :-)
i did it with : value="<?php echo "$fIndex"; ?>"

You could just do value="<?=$fIndex?>"[/quote]
Hi interesting whats is mean "=" in your script, - never use this....

Posted: Sat Aug 17, 2002 12:53 pm
by Jay
WiZARD wrote:Hi interesting whats is mean "=" in your script, - never use this....

It's take from ASP I believe. It just means to output quickly, an alternative to echo or write! Very good for writing small scripts, and you can even use it with functions, eg:
value="<?=$url.$page.urlencode($someVariable)?>"

Or even:

value="<?=($value)? "Yes":"No"?>"

You just use it for single line scripts!