Re: [PHP] preserving variable values across pages.

2002-02-11 Thread Jason Wong

On Tuesday 12 February 2002 14:22, Tehn Yit Chin wrote:
> Hi all,
>
> If I have the following code,
>
>global $some_var
> 
>   type="submit" name="submit" value="foobar">
> 
> ?>
>
>
> When the user hits the submit button, the value in some_var disappears? Is
> there a way of perserving the value in $some_var.


GLOBAL in php is not the same as global in ASP. It is only global within the 
lifetime of the script. What you need is a hidden element in your form 
holding the value of $some_var.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] preserving variable values across pages.

2002-02-11 Thread Keith V. (Vance Consulting LLC)

You could do it a number of ways.
1. Use a hidden input field in your form,. 
2. Put $some_var in a session variable.
3. Pass the value of some_var in the url.

Each has it's advantages/disadvantages. Just remember that just because you say 
something is global doesn't mean it's global to every page, it's global on that page. 
global can be used as follows:



If I didn't specify global $var inside the function the function wouldn't be able to 
"see" the $var variable I defined outside the function and would have just printed 
"Dude that's a " instead of "Dude that's a 1"

Hope that helps.

On 12 Feb 2002 at 17:22, Tehn Yit Chin wrote:

> Hi all,
> 
> If I have the following code,
> 
>global $some_var
> 
>   type="submit" name="submit" value="foobar">
> 
> ?>
> 
> 
> When the user hits the submit button, the value in some_var disappears? Is
> there a way of perserving the value in $some_var.
> 
> thanks in advance.
> 
> cheers,
> Tehn Yit
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


K E I T H  V A N C E
Web Developer, IT Professional
http://www.vanceconsulting.net
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] preserving variable values across pages.

2002-02-11 Thread Tehn Yit Chin

Hi all,

If I have the following code,


type="submit" name="submit" value="foobar">

?>


When the user hits the submit button, the value in some_var disappears? Is
there a way of perserving the value in $some_var.

thanks in advance.

cheers,
Tehn Yit


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] preserving variable values across pages.

2002-02-11 Thread Andrew Slezak

Found this on the php.net, querying the PHP mailing list:

">test.php
--
$blah=10;
include "whatever.php";


>whatever.php
-
echo "The value of blah is: {$blah}";


It just keeps the variable since it's global..

When ur using a function. It can be different, since you have to
import these variables."


HTH,
Andy
- Original Message -
From: "Tehn Yit Chin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, February 12, 2002 1:22 AM
Subject: [PHP] preserving variable values across pages.


> Hi all,
>
> If I have the following code,
>
>  global $some_var
> 
> type="submit" name="submit" value="foobar">
> 
> ?>
>
>
> When the user hits the submit button, the value in some_var disappears? Is
> there a way of perserving the value in $some_var.
>
> thanks in advance.
>
> cheers,
> Tehn Yit
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php