[PHP] POST variabelen

Pagina: 1
Acties:

  • KolNedra
  • Registratie: September 2001
  • Laatst online: 18-04-2020
Ik wil heb een script nodig die een voor een de gePOSTe variabelen afgaat...

M.a.w deze variabelen hebben elke keer een andere naam
Dus een:
if ($naam) { }
is niet mogelijk omdat het elke keer dit is:
$naam<var> die <var> is een variabelle string
Hoe pak ik dit nou aan?

::: flickr.com/kolnedra ::: Nikon D80 + Sigma 18-200mm f/3.5-6.3 DC + Sigma 10-20mm f/4-5.6 EX DC HSM


  • Orphix
  • Registratie: Februari 2000
  • Niet online
PHP:
1
2
3
4
5
6
<?
foreach($_POST as $postVariabele)
{
... doe er iets mee
}
?>

  • elnino
  • Registratie: Augustus 2001
  • Laatst online: 03-09 05:13
Om POST af te vangen kun je het beste $HTTP_POST_VARS["varnaam"] gebruiken. Als je een variabele wilt afvangen met de naam "emailadres", dan doe je dat dus met $HTTP_POST_VARS["emailadres"].

  • rookie
  • Registratie: Februari 2000
  • Niet online
Uit de documentatie van PHP:
PHP:
1
2
3
4
5
6
7
<?
echo "Values submitted via POST method:<br>";
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
    echo "$key => $val<br>";
}
?>

  • elnino
  • Registratie: Augustus 2001
  • Laatst online: 03-09 05:13
Op woensdag 13 februari 2002 13:11 schreef Orphix het volgende:
PHP:
1
2
3
4
5
6
<?
foreach($_POST as $postVariabele)
{
... doe er iets mee
}
?>
Helaas heeft nog niet iedereen PHP 4.1.0 of hoger... misschien is $HTTP_POST_VARS daarvoor handiger...

  • TheRookie
  • Registratie: December 2001
  • Niet online

TheRookie

Nu met R1200RT

Predefined Variables

misschien kan je
$HTTP_POST_VARS
An associative array of variables passed to the current script via the HTTP POST method.

$_POST
An associative array of variables passed to the current script via the HTTP POST method. Automatically global in any scope. Introduced in PHP 4.1.0.
iets mee ?
Pagina: 1