[PHP] Lost variables

2004-11-24 Thread Alberto Brea
Perhaps. I always use the same phrase to open up an array.
foreach($myarray as $var=$val) { $$var= $val; }
You can also nest it into another foreach statement to extract from an
associative array.

Alberto




__
Renovamos el Correo Yahoo!: ¡100 MB GRATIS!
Nuevos servicios, más seguridad
http://correo.yahoo.es

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



[PHP] Lost Variables

2004-11-23 Thread Monique Verrier
First -- thank you for reading my post.

I am using the general strategy suggested by Jay (thanks, Jay) to process my
form in another procedure.  It's listed below.  In my processStuff.php
program, I use the following code:

$attributes = array();
$attributes = array_merge($attributes,$HTTP_POST_VARS, $HTTP_GET_VARS);
extract($attributes, EXTR_PREFIX_SAME, this);

I want to load my numerous post variables into regular memory variables (or
whatever the php nomenclature is) -- e.g. $_POST['action'] becomes $action.
It doesn't seem to working according to the manual.  I list my
$HTTP_SESSION_VARS, there are none.

I would appreciate anyone taking the time to explain to me how this works.
Either it's stupid or I'm stupid.  I'm figuring it's me.

Monique.




form method=post name=form1 action=processStuff.php
input type=submit name=action value=Add Record
input type=submit name=action value=Delete Record

In processStuff.php

?php
switch ($_POST['action']){
case Add Record:
...do stuff...
..redirect back to original page...
break;

case Delete Record:
...do stuff...
..redirect back to original page...
break;

}
?

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



Re: [PHP] Lost Variables

2004-11-23 Thread abrea
To turn $_POST[var1], $_POST[var2], $_POST[var3] into $var1, $var2, 
$var3:

if(isset($_POST))
 { foreach($_POST as $key=$value)
 { $$key= $value; print($$key= $value; br /); }}

This should do it. The print statement is just to check the result.
Regards

Alberto Brea


-Original Message-
From: Monique Verrier [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Date: Tue, 23 Nov 2004 12:52:29 -0800
Subject: [PHP] Lost Variables

 First -- thank you for reading my post.
 
 I am using the general strategy suggested by Jay (thanks, Jay) to
 process my
 form in another procedure.  It's listed below.  In my processStuff.php
 program, I use the following code:
 
 $attributes = array();
 $attributes = array_merge($attributes,$HTTP_POST_VARS, $HTTP_GET_VARS);
 extract($attributes, EXTR_PREFIX_SAME, this);
 
 I want to load my numerous post variables into regular memory variables
 (or
 whatever the php nomenclature is) -- e.g. $_POST['action'] becomes
 $action.
 It doesn't seem to working according to the manual.  I list my
 $HTTP_SESSION_VARS, there are none.
 
 I would appreciate anyone taking the time to explain to me how this
 works.
 Either it's stupid or I'm stupid.  I'm figuring it's me.
 
 Monique.
 
 
 
 
 form method=post name=form1 action=processStuff.php
 input type=submit name=action value=Add Record
 input type=submit name=action value=Delete Record
 
 In processStuff.php
 
 ?php
 switch ($_POST['action']){
 case Add Record:
 ...do stuff...
 ..redirect back to original page...
 break;
 
 case Delete Record:
 ...do stuff...
 ..redirect back to original page...
 break;
 
 }
 ?
 
 -- 
 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



Re: [PHP] Lost Variables

2004-11-23 Thread Monique Verrier
Thank you, Alberto.  Do you know -- does the extract() function not work?

Monique.


Abrea [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
 To turn $_POST[var1], $_POST[var2], $_POST[var3] into $var1, $var2,
 $var3:

 if(isset($_POST))
  { foreach($_POST as $key=$value)
  { $$key= $value; print($$key= $value; br /); }}

 This should do it. The print statement is just to check the result.
 Regards

 Alberto Brea


 -Original Message-
 From: Monique Verrier [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Date: Tue, 23 Nov 2004 12:52:29 -0800
 Subject: [PHP] Lost Variables

  First -- thank you for reading my post.
 
  I am using the general strategy suggested by Jay (thanks, Jay) to
  process my
  form in another procedure.  It's listed below.  In my processStuff.php
  program, I use the following code:
 
  $attributes = array();
  $attributes = array_merge($attributes,$HTTP_POST_VARS, $HTTP_GET_VARS);
  extract($attributes, EXTR_PREFIX_SAME, this);
 
  I want to load my numerous post variables into regular memory variables
  (or
  whatever the php nomenclature is) -- e.g. $_POST['action'] becomes
  $action.
  It doesn't seem to working according to the manual.  I list my
  $HTTP_SESSION_VARS, there are none.
 
  I would appreciate anyone taking the time to explain to me how this
  works.
  Either it's stupid or I'm stupid.  I'm figuring it's me.
 
  Monique.
 
 
 
 
  form method=post name=form1 action=processStuff.php
  input type=submit name=action value=Add Record
  input type=submit name=action value=Delete Record
 
  In processStuff.php
 
  ?php
  switch ($_POST['action']){
  case Add Record:
  ...do stuff...
  ..redirect back to original page...
  break;
 
  case Delete Record:
  ...do stuff...
  ..redirect back to original page...
  break;
 
  }
  ?
 
  -- 
  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



Re: [PHP] Lost Variables

2004-11-23 Thread Jason Wong
On Wednesday 24 November 2004 04:52, Monique Verrier wrote:

 I am using the general strategy suggested by Jay (thanks, Jay) to process
 my form in another procedure.  It's listed below.  In my processStuff.php
 program, I use the following code:

 $attributes = array();
 $attributes = array_merge($attributes,$HTTP_POST_VARS, $HTTP_GET_VARS);
 extract($attributes, EXTR_PREFIX_SAME, this);

 I want to load my numerous post variables into regular memory variables (or
 whatever the php nomenclature is) -- e.g. $_POST['action'] becomes $action.
 It doesn't seem to working according to the manual.

How is it not working? What does var_dump($attributes) show?

 I list my $HTTP_SESSION_VARS, there are none.

Is this related to the above? $HTTP_SESSION_VARS would normally be empty 
unless you start a session and register some session variables.

 I would appreciate anyone taking the time to explain to me how this works.
 Either it's stupid or I'm stupid.  I'm figuring it's me.

1) Usually there is little point putting the request variables 
($HTTP_POST_VARS, $HTTP_GET_VARS, $_GET, $_POST) into the local namespace. 
Just use them directly as you have here:

 switch ($_POST['action']){
 case Add Record:
 ...do stuff...

2) If you really must do (1) then instead of:

   extract($attributes, EXTR_PREFIX_SAME, this);

you should probably use this:

   extract($attributes, EXTR_PREFIX_ALL, this);

that way you'll know that variables prefixed with 'this' came from 
$HTTP_POST_VARS, $HTTP_GET_VARS. BTW why are you processing $HTTP_GET_VARS? 
You're using POST for your form.

3) To save confusion use only the new superglobals ($_POST, $_GET etc) OR 
only the old, deprecated request variables ($HTTP_POST_VARS, $HTTP_GET_VARS). 
Do not mix the two in the same code. See manual for details.

-- 
Jason Wong - Gremlins Associates - www.gremlins.biz
Open Source Software Systems Integrators
* Web Design  Hosting * Internet  Intranet Applications Development *
--
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
--
/*
BOFH Excuse #248:

Too much radiation coming from the soil.
*/

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