Re: scope of a variable
| From: | Dean Hall | Date: | Fri, 18 Aug 2000 21:17:51 +0000 |
| Subject: | Re: scope of a variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-12536@lists.php.net to get a copy of this message | ||
Don't forget, PHP is all server-side. All the client (www browser) knows is
what you send it, so you have to tell it to remember your $poliza array. The
best way I can think of would be to do the following inside your form:
<?
foreach($poliza as $key => $val) {
?>
<input type="hidden" name="poliza[<?=$key?>]"
value="<?=$val?>">
<?
}
?>
This will do something like this on the HTML page:
<input type="hidden" name="poliza[tipo]" value="tipo">
<input type="hidden" name="poliza[numero]" value="">
And on for all values in $poliza. When the client submits the form, PHP will
read this array in as a variable in $HTTP_POST_VARS, and if you have
track-vars set, it'll show up as a global.
Dean.
----- Original Message -----
From: "Omar Armas Aleman" <oarmas@mps.com.mx>
To: "Php-General@Lists. Php. Net" <php-general@lists.php.net>
Sent: Friday, August 18, 2000 1.04 pm
Subject: [PHP] scope of a variable
>
> I have a variable $poliza like this:
> $poliza = array(
> "tipo" => $tipo,
> "numero" => "",
> "cliente_id" => "",
> "poliza_id" => ""
> );
>
> which I populate and use at a file called "polizanueva.php".
>
> Well, my problem is that from this file, users are redirected to another
> file with:
> file://this is in polizanueva.php
> printf("<FORM action=caso.php method=post>");
> printf("<INPUT type=submit value='Registrar caso'>");
> printf("</FORM>");
>
> How can I preserve the values of $poliza(defined in polizanueva.php) from
> the file caso.php?
>
> I tried declaring it global, but doesn't work.
> Is there a way to pass it like a parameter in the FORM declatarion?
>
> Thanks.
>
>
>
> --
>
> Omar
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net