You are here: Re: Can I get the form name from $_POST? « All PHP « IT news, forums, messages
Re: Can I get the form name from $_POST?

Posted by shimmyshack on 02/26/07 19:04

On 26 Feb, 13:05, "J.O. Aho" <u...@example.net> wrote:
> bissa...@yahoo.co.uk wrote:
> > Hi,
>
> > When I submit a form, I use the $_POST thingy to get the form values.
> > Is it possible to get the form name from this method?
>
> > For example:
>
> > <form name="form1" method="post" action="...">
> > <input type="text" name'"name"... .
> > </form>
>
> > When I submit the form I will get the POST variable "name" as well as
> > any other form elements that are submitted. Can I also get the form
> > name, "form1"?
>
> No, the form "name" isn't sent with the form submit, the "name" option
> is a depricated way of selecting the correct style from CSS or target
> the right part of the page with javascript, it's higly encuraged that
> people shouldl use "id" instead of "name".
> And the answer for your next question is, no, the "id" won't be sent
> when you submit the form, it's still used for CSS and javascript.
>
> If you want to send a "form id" then either use the submit button or use
> a hidden input field
>
> example 1 (button):
>
> <form method="post" action="...">
> <input type="text" name'"name"...
> <button type="submit" name="form1" value="form1">Submit</button>
> </form>
>
> example 2 (hidden):
>
> <form method="post" action="...">
> <input type="text" name'"name"...
> <inout type="hidden" name="form1" value="form1">
> <button type="submit">Submit</button>
> </form>
>
> Keep in mind that method 1 don't work on the broken browser, but works
> fine in khtml/gecko/opera.
>
> --
>
> //Aho

you can also choose to name you fields after the form (here are 2
forms in the same page)
<html>
<head></head>
<body>
<form method="post" action="..." name="form2">
<input type="text" name="form1[field1]"... />
<input type="text" name="form1[field2]"... />
<button type="submit">Submit</button>
</form>
<form method="post" action="..." name="form2">
<input type="text" name="form2[field1]"... />
<input type="text" name="form2[field2]"... />
<button type="submit">Submit</button>
</form>
</body>
</html>

you then use an array called by the name of the form to get the values
out in say php

 

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

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