Re: Can I get the form name from $_POST?
- From: "kenoli" <kenoli.p@xxxxxxxxx>
- Date: 27 Feb 2007 08:41:53 -0800
This is timely for me as well. I was trying to figure out how to
process diferent groups of form imput and discovered that form names
are not sent via the $_POST variable. Your way of coding this is a
good solution. I presume when using multiple forms like this, a
submit in a given form only sends data from the input fields in that
form rather than from all the forms on the page. Is this true?
--Kenoli
On Feb 26, 11:04 am, "shimmyshack" <matt.fa...@xxxxxxxxx> wrote:
On 26 Feb, 13:05, "J.O. Aho" <u...@xxxxxxxxxxx> wrote:
bissa...@xxxxxxxxxxx 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
.
- Follow-Ups:
- Re: Can I get the form name from $_POST?
- From: J.O. Aho
- Re: Can I get the form name from $_POST?
- References:
- Can I get the form name from $_POST?
- From: bissatch
- Re: Can I get the form name from $_POST?
- From: J.O. Aho
- Re: Can I get the form name from $_POST?
- From: shimmyshack
- Can I get the form name from $_POST?
- Prev by Date: Re: saving content from another site
- Next by Date: Re: File extensions
- Previous by thread: Re: Can I get the form name from $_POST?
- Next by thread: Re: Can I get the form name from $_POST?
- Index(es):