Solved

Hitting the POST variable limit

Posted on 2014-03-14
16
308 Views
Last Modified: 2014-03-25
Hi Experts,

I have an admin page on a site I'm maintaining that displays the contents of a database table.

each row has 50 fields, and when the table is displayed on the admin page, every field is editable

right now i have it as part of a form, and on clicking submit, the database table is updated with the contents of the fields.

My issue comes in now that there are more than 20 rows (42 actually, totaling 2100 fields).

POST limits this to 1000 "fields".  I can't change the apache settings (it's hosted and they won't change it for me), and adding

php_value upload_max_filesize 12M
php_value post_max_size 32M

to the .httaccess file gives a 500 error.

Anyone have a brilliant suggestion on how to handle this?

I thought instead of having 2100+ 'inputs' in the form, of having only one input on the form: a very long string containing all the values of the table that i could pass as 1 post variable and parse as an array upon submit - using JavaScript to handle the changes as the user enters / changes data and writing that data to the string.

Any suggestions that are better than that?
0
Comment
Question by:sgaggerj
  • 4
  • 3
  • 3
  • +4
16 Comments
 
LVL 32

Assisted Solution

by:Big Monty
Big Monty earned 83 total points
Comment Utility
there is a post size limit as well (I don't have the number off the top of my head right now) but you may run into that issue as well.

Depending on how much re-coding you want to do, you could turn the form into an ajax based form and save x amount of fields at a time, that way you could control the number of fields you pass across
0
 
LVL 108

Assisted Solution

by:Ray Paseur
Ray Paseur earned 83 total points
Comment Utility
Find out if the host has Suhosin installed.  If they do, ask them to disable it.  There should be no practical limit on the number of POST input controls, and the overall limit of the POST request is somewhere near the 2 billion byte mark.  If your host can't fix this (it is their problem, not yours), consider getting a new hosting company.
0
 
LVL 58

Assisted Solution

by:Gary
Gary earned 83 total points
Comment Utility
Are all fields going to be changed?
This sounds like a case for ajax and just update the fields as they are changed
0
 
LVL 82

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 83 total points
Comment Utility
On the different hosting companies I use, I find the "post_max_size" in 'php.ini' set to 8M, 25M, 33M, and 108M.
0
 
LVL 51

Assisted Solution

by:Julian Hansen
Julian Hansen earned 83 total points
Comment Utility
The number of fields should not be relevant - what is relevant is the post size. Fields in a post are just a concatenated string - so the number should not matter.

However if you are hitting the limit on the post size you might need to increase it

There are two ways to do this - but your ISP might need to be involved to do this

php.ini

post_max_size=XXM
upload_max_filesize=XXM

.htaccess

php_value post_max_size XXM
php_value upload_max_filesize XXM
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
The number of fields should not be relevant
Unless your host has Suhosin installed.  Suhosin usually limits the number of fields to 1000.
0
 
LVL 1

Author Comment

by:sgaggerj
Comment Utility
As far as I can tell I'm limited to 1000 post fields.  each row has two fields for text description and the other 48 are currency values (ie 0.00, 1.25, etc).  I've changed all the text descriptions to two characters each and was still limited to 1000 fields in $_POST[]

As far as the length of each field it's between 4 characters (0.00) and the length of a description (varies from line to line from 4 to 20)

I don't know ajax at all so that probably won't help me much.

I'll check with the hosting provider again and see what they can do.

I don't believe I have access to my php.ini file to change....

I may change the naming convention on each of the individual <input> tags, putting them outside my form, and use Javascript to create a string with what key => values were changed - rather than changing them all every time - and submit just that string on update.
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
With AJAXyou would only submit fields as they are changed, you wouldn't be submitting the whole form.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 33

Assisted Solution

by:Slick812
Slick812 earned 83 total points
Comment Utility
Just my way to deal with this, is to divide up large Data sets, presented to to the user on the page, Almost every one can work better with understandable amounts of  digital data (Rows or elements of page output), You say -"My issue comes in now that there are more than 20 rows", , so you might could put a display of 15 rows at a time, might solve the Max limit problem and be more user friendly? ?
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Does the limit apply if you use arrays?
0
 
LVL 1

Author Comment

by:sgaggerj
Comment Utility
@slick812

Part of my problem comes in due to the fact that the owner of this site wants all the rows visible in a scrollable form.



I think I came up with a solution which appears to be working.  

I have to test it out over the weekend.

I'll post back with results.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
There are still methods to only submit smaller parts that have changed instead of the whole table.
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
owner of this site wants all the rows visible...
A reasonable request.  The owner should be willing to pay for a hosting company that can implement this without artificial limits.
0
 
LVL 51

Expert Comment

by:Julian Hansen
Comment Utility
Have you considered using AJAX updating - after editing only those fields that have changed a are updated through AJAX?
0
 
LVL 1

Accepted Solution

by:
sgaggerj earned 0 total points
Comment Utility
@ Dave Baldwin:
Yep, that's what I ended up doing.
my form has 1 input (hidden) as a key.  Each entry in the displayed table when changed will add to the key in the form:  <id:value>;<id:value>..... that gets updated via JavaScript.
Then on submit that key is passed and parsed by my php script updating the db table.

@ Ray Paseur:
True, however he doesn't have alot of money to switch (nor do I honestly have the desire or the time to switch things for him nor get involved with his host).  Kind of have to work with what I have.

@  julianH:
Yea I looked at it real quick, but don't know AJAX at all to be able to implement it.  This is a side "job" helping out a friend and I don't have a ton of time to spend on it.

So the long and short of it is I figured it out, doing what I described above.

I really appreciate all of your input on this and will look at how to distribute points to everyone for their input.  

Thanks!
0
 
LVL 1

Author Closing Comment

by:sgaggerj
Comment Utility
Used my own solution stated in my post above this.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now