You are here: Re: Getting variable names passed to form in php « PHP Programming Language « IT news, forums, messages
Re: Getting variable names passed to form in php

Posted by Rik Wasmus on 10/14/07 11:37

On Sun, 14 Oct 2007 13:13:30 +0200, <william.hooper@gmail.com> wrote:

> If I have a form:
>
> <FORM ACTION=3D"test.php"><INPUT TYPE=3DSUBMIT NAME=3D"hello"
> VALUE=3D"Delete"> </FORM>
>
> then in test.php I could write:
>
> $value =3D $_POST['hello'];
>
> to set $value=3D"Delete".
>
> But what if I wanted to get "hello" out instead of "Delete". Ie how
> can I tell the variables inside the porm submit instead of just the
> values of the variables?
>
> Many Thanks... I am new to PHP and can not find this info despite
> searching around for a while!

Examining the $_POST array.
So, for instance:
<?php
if(!empty($_POST)){
foreach($_POST as $key =3D> $value){
//'hello' should be a key:
echo ""$key:$value\n";
}
}
?>
If you only want the array keys, use array_keys($_POST) for that.
-- =

Rik Wasmus

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация