PDA

View Full Version : PHP Top Tip - big forms and POSTS


davidj
08-16-2006, 03:45 PM
When dealing with big forms with allot of elements (fields)

name all elements using the convension...


<input name="FormField[]"
<input name="FormField[]"
<input name="FormField[]"


this will set all field data to an Array which can be accessed using...



$formfield = $_POST['FormField']; // << Array

$formfield[0] || $formfield[1] || $formfield[2] etc // << Access Array



imagine 20-30 form elements which would normally require 20-30 $_POST's !

Not any more... Just the one $_POST thankyou sir

cozybuilder
12-01-2006, 01:06 PM
I am new to this world and it's taken me quite a long time to get to this point. I thought I was almost done, and ready for the BIG presentation on tuesday, but I was wrong. I hope this can be resolved easily.

I've created an update form with 170 fields. When it runs it returns the "to many fields" error message. I knew the limit was 255 for access, what I did not know is that an update form requires 2 "fields" for every 1.

My first thoughts were to somehow split the update on the same form. ie. clicking the update button would send the first 85 fields, reload the page, then send the other 85 fields.

This post looked promising, can I use this "array" method to repair this form?

Any help is GREATLY appreciated.

Jack Fairchild
Dreamweaver 8.0
ASP/VBScript, IIS, Access 2003

davidj
12-01-2006, 01:55 PM
I've created an update form with 170 fields.

Thats a beasty!
When it runs it returns the "to many fields" error message. I knew the limit was 255 for access, what I did not know is that an update form requires 2 "fields" for every 1.


the form requires 1 field for every field required ???

cozybuilder
12-01-2006, 02:15 PM
the form requires 1 field for every field required ???

Is that a double negative?

All I was saying is that: when Access says you are limited to 255 entries, it is really 127 for update forms.

example: update A:B, B:C
The form would only show two fields A and C, but it sends four.

Sorry if the syntax is incorrect.

Jack Fairchild

cozybuilder
12-01-2006, 02:38 PM
Please don't be to hard on me, I design fire protection systems by day. I can give you an excellent pre-action, co2, inergen, FM2000, halon or some other clean agent to protect your servers. But put me inside the box, and I am still a little green.

OK, gave up on that... The zip file is 12KB, but the forum says I am exceeding the limit???

Must be me, always exceeding the limit.

Jack Fairchild

davidj
12-01-2006, 03:16 PM
OK, gave up on that... The zip file is 12KB, but the forum says I am exceeding the limit???

Dom. sort this out . Up the upload limit size please.

ok

I am not an ASP developer but i doubt that you need 2 fields for 1 input

i am asuming that you have 2 form fields for 1 database field?? this is wrong. I cant under stand why you would need 2 for 1.

179 fields. I am assuming you have as many fields in a table in your access db? This must be a nightmare to administer

cozybuilder
12-01-2006, 03:38 PM
i am asuming that you have 2 form fields for 1 database field?? this is wrong.

Yes, error in translation see http://support.microsoft.com/?id=199076

This must be a nightmare to administer

Haven't tried that yet, but you are scaring the crap out of me...

Jack

cozybuilder
12-01-2006, 03:50 PM
David,

I see from your profile that you took some flying lessons, I am currently building an experimental from plans. See my plane in progress my website...

http://www.maddyhome.com/canardpages/pages/cozybuilder/index.html

Also a part grain brewer.

Jack

domedia
12-01-2006, 04:40 PM
Dom. sort this out . Up the upload limit size please. Should be better now, good thing I looked in this thread ;)

cozybuilder
12-01-2006, 05:00 PM
Here's the code, but sadly it appears that Dreamweaver is already using an array. I think I have figured out a way to split the forms (not happy about it though).

Jack

davidj
12-01-2006, 06:02 PM
I am currently building an experimental from plans


lovely looking machine although aircraft and experimental should not exist in the same sentence!

domedia
12-01-2006, 08:37 PM
lovely looking machine although aircraft and experimental should not exist in the same sentence!
And I here I was thinking it was DJ and Aircraft 8-)

davidj
12-01-2006, 09:26 PM
hey i was a good student pilot

although couldnt get that hover mastered!

cozybuilder
12-01-2006, 10:23 PM
lovely looking machine although aircraft and experimental should not exist in the same sentence!

The only affordable way to do it. Not going to find a 4 seat, 220knot aircraft for $40,000 anywhere else.

Thanks for the assistance.

Jack
When I fly her across the pond I'll give you a ride...IF YOU'RE WILLING :)

davidj
12-01-2006, 11:11 PM
aye that would be great

kona72
12-03-2006, 03:03 PM
Hey Dj,

Tried this method of posting using array. My issue is how do i call on them with out just getting 'array'?

Not sure if i explained my self properly...

Hmmmmm....

davidj
12-03-2006, 04:33 PM
if you have...


<input name="FormField[]"
<input name="FormField[]"
<input name="FormField[]"


you can access this array by ...


$FormField = $_POST['FormField'];

echo $FormField[0];
echo $FormField[1];
echo $FormField[2];


or you could use an array naming convention


<input name="FormField[id_field]"
<input name="FormField[data_field]"
<input name="FormField[data_field2]"

$FormField = $_POST['FormField']; // << using 1 $_POST

echo $FormField[id_field];
echo $FormField[data_field];

// with this method you can catch all your fields in 1 $_POST but can target
them using the name set in the element rather than using an incrementing number


if you want to test your array var the you can use print_r($FormField);