Re: forms and variables?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, April 21, 2006 7:45 am, William Stokes wrote:
> In PHP. Is it possible to point to a variable with the HTML form name
> by
> which it was posted from?

The FORM name attribute was an add-on for Javascript client-side.

It is not transmitted by HTTP.

PHP never sees it.

> Or do I just have name the variables uniquely?

Yes.

Or you could just add ONE new INPUT in each form to tell you which
FORM was used:
<INPUT TYPE="HIDDEN" NAME="FORM" VALUE="AddNew" />


Or you could have just ONE form and use buttons with name for your
INPUTs:
<form name="irrelevant" ...>
   <input type="submit" name="AddNew" value="Add" />
   <input type="submit" name="DeleteOld" value="Del" />
</form>

The button the user clicked on is sent as a variable with HTTP.
EXCEPTIONS:
If there is only ONE submit button, and if the user hits "Enter" (aka
"Return") instead of actually clicking on the button, then some
browser do not send the button name/value.
If you use JavaScript to do the submit, it's your problem to add
whatever inputs you need in JavaScript to make things work... As well
as anything in JavaScript works, anyway.

Or you could have the FORMs have different ACTION attributes so you
know which form sent the data because you have scripts dedicated to a
specific purpose instead of some monolithic mess trying to be-all
do-all end-all.

Or you can use arrays in the NAME attributes to organize things in
some cases -- probably not in this particular instance, but keep it in
mind for INPUT elements within the same form.

-- 
Like Music?
http://l-i-e.com/artists.htm

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux