473,396 Members | 1,827 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

multi-form variables

I have read quite a few posts and can't seem to find the answer to my
question. I need to be able to pass from fields to PHP from severel
different forms on a page. I have had to create multiple forms
because I am dynamically adding and subtracting form elememts of
various types in javascript based on user activity. My problem now is
getting all of these different form fields to PHP so I can write them
to MySQL. I am open to any suggestions and will try using cookies,
javascript arrays, hidden form fields, or whatever it takes. The only
drawback is I have to use multiple forms so combining forms is not an
option.
Jul 17 '05 #1
3 3650
Greg Mascherino wrote:
I need to be able to pass from fields to PHP from severel
different forms on a page.
Only if they have the same name.

[...]
I am open to any suggestions and will try using cookies,
javascript arrays, hidden form fields, or whatever it takes.
Maybe (I don't know JavaScript) you can pull all values from all forms
when you click a "submit" and put them in hidden fields of another form
and POST _that_ form to PHP.

The only
drawback is I have to use multiple forms so combining forms is not an
option.


try this:

<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
echo '<pre>'; print_r($_POST); echo '</pre>';
}
echo <<<HTML
Form1:
<form name="form1" action="" method="post">
<input type="hidden" name="both" value="both"/>
<input type="hidden" name="oneonly" value="oneonly"/>
<input type="submit"/>
</form>
<br/><hr/><br/>
Form2:
<form name="form2" action="" method="post">
<input type="hidden" name="both" value="both"/>
<input type="hidden" name="twoonly" value="twoonly"/>
<input type="submit"/>
</form>
HTML;
?>
When you submit the first form you'll be able to access $_POST['both']
and $_POST['oneonly'], but not $_POST['twoonly'].

Likewise for submitting the second form -- no $_POST['oneonly'].

--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2
You must not use multiple forms.

Why do you think you have to?

--
mfg Christian (Chronial "at" web.de)

--
Composed with Newz Crawler 1.5 http://www.newzcrawler.com/
Jul 17 '05 #3
Hello,

On 12/15/2003 06:31 PM, Greg Mascherino wrote:
I have read quite a few posts and can't seem to find the answer to my
question. I need to be able to pass from fields to PHP from severel
different forms on a page. I have had to create multiple forms
because I am dynamically adding and subtracting form elememts of
various types in javascript based on user activity. My problem now is
getting all of these different form fields to PHP so I can write them
to MySQL. I am open to any suggestions and will try using cookies,
javascript arrays, hidden form fields, or whatever it takes. The only
drawback is I have to use multiple forms so combining forms is not an
option.

You may want to take a look at this class. It passes fields between
pages using just hidden fields.

http://www.phpclasses.org/multipageforms

--

Regards,
Manuel Lemos

Free ready to use OOP components written in PHP
http://www.phpclasses.org/

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: ajikoe | last post by:
Hello, Is anyone has experiance in running python code to run multi thread parallel in multi processor. Is it possible ? Can python manage which cpu shoud do every thread? Sincerely Yours,...
4
by: Frank Jona | last post by:
Intellisense with C# and a multi-file assembly is not working. With VB.NET it is working. Is there a fix availible? We're using VisualStudio 2003 Regards Frank
12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
0
by: frankenberry | last post by:
I have multi-page tiff files. I need to extract individual frames from the multi-page tiffs and save them as single-page tiffs. 95% of the time I receive multi-page tiffs containing 1 or more black...
6
by: cody | last post by:
What are multi file assemblies good for? What are the advantages of using multiple assemblies (A.DLL+B.DLL) vs. a single multi file assembly (A.DLL+A.NETMODULE)?
4
by: mimmo | last post by:
Hi! I should convert the accented letters of a string in the correspondent letters not accented. But when I compile with -Wall it give me: warning: multi-character character constant Do the...
17
by: =?Utf-8?B?R2Vvcmdl?= | last post by:
Hello everyone, Wide character and multi-byte character are two popular encoding schemes on Windows. And wide character is using unicode encoding scheme. But each time I feel confused when...
0
by: Sabri.Pllana | last post by:
We apologize if you receive multiple copies of this call for papers. *********************************************************************** 2008 International Workshop on Multi-Core Computing...
1
by: mknoll217 | last post by:
I am recieving this error from my code: The multi-part identifier "PAR.UniqueID" could not be bound. The multi-part identifier "Salary.UniqueID" could not be bound. The multi-part identifier...
2
by: Aussie Rules | last post by:
Hi, I have a site that Iwant to either display my text in english or french, based on the users prefernces ? I am new to webforms, but I know in winforms, this is pretty easy with a resource...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.