Size of post too big - php

I got a database that currently is pretty big (and even gets bigger by time).
I got a webpage on which I present the data in a form, so it can be changed.
I send it with method post.
This worked pretty well until the data got too much. Now it tells me 'it exceeds the limit of 1000'.
I read that I could change post_max_size in php.ini but I cant do it on my webserver, so its not really an option for me. Is there anything else I can do? The problem is, that ALL THE SHOW data will be in post, not only the changed one. Is there something that would do the trick?

I don't know the type and setup of your web-server, but post_max_size can be set in an .htaccess file:
php_value post_max_size 10000
Alternatively you could only send the values that have changed. If you use ajax to post your form, you could set - and check for - for example a data attribute like modified set on the fields.
By the way, I am assuming that you are talking about individual posts and are not sending your whole database back-and-forth. If you offer editing of a collection of items, you should use something like pagination to limit the number to a fixed maximum.

Related

$_POST not containing all input data

I'm trying to post a large form through php using POST method. My form post script has been working fine until now that the $_POST array got pretty large.
When i print out file_get_contents('php://input'); ,all the inputs that are included in the form, are shown. But when i print out $_POST, it only gets the first part of the form. I've tried to remove rows and then the $_POST method works fine again. As soon as it gets too large, it won't post all data included in the form.
Anyone got any ideas? I've tried to edit php.ini and set post_max_size to a higher value, but it didn't help either.
By default, in lower versions of PHP(< 5.3.9) the number of $_POST variables is limited to 1000. There is no way to change that.
In higher versions you can set max_input_vars to whatever number you wish.
If you're below 5.3.9 there are some work-arounds you can do. For example json_encode the variables and send them as a single variable. The limit of $_POST is set to 8mb by default but can be changed in the php.ini file post_max_size="whatever_size_you_wish_here".
How to increase the number of variables in $_POST:
2 options:
in your .htaccess file do php_value max_input_vars 2000(or whatever)
in the file you're working with ini_set('max_input_vars', 2000);
Try dumping a phpinfo() and look for max_input_vars. If it's there, you can set it in php.ini to a higher number, as you see fit. If you don't see it, it's likely that you didn't receive that exact patch and the number has been hard-coded by your distribution.
Just solved it, apparently my server didn't update max_input_vars for some strange reason. Now that i increased that value it's working.

userform input not always transferring to database

I have an admin section to my website where I can update a blog using a userform I created. I set the database datafields in phpmyadmin to "text" and my html textarea to a maxlength of 100000. But if I try to submit an article I typed that's longer than a paragraph, it doesn't update in phpmyadmin. It works fine for maybe 300 characters, but if it gets longer than that, it doesn't update. Am I missing a setting somewhere? I'm an amateur. Do I need to use a Getquerystring function for larger amounts of data? Or is it because I'm just doing it on a localhost? Thanks in advance.
I would take a look at your servers settings.
<?php phpinfo(); ?>
in your php.ini, there are variables like post_max_size, max_get_size, and max_input_vars. It is possible that these settings are preventing your from using what you wish.
For example:
post_max_size = 2M
2Mb is = 2000000 bytes

Long PHP FORMs are cut off when they are submitted

I have one page with a large form inside: Table with more than 2000 vars.
I know about max_input_vars and in my php.ini I set:
max_input_vars = 3000
But the problem is the same.
If I make the count, only 1000 variables are returned.
When I am using
var_dump(ini_get('max_input_vars'));
The result is 3000:
Do you know where I can be wrong?
I am using symfony, is tehre any difference?
If you exceed max_input_vars you would get a PHP Warning: Input variables exceeded 1000 so it must be related to something else.
First you need to make sure that the browser is sending all the data. You can do some debugging via browser console, eg. serialize the form $('#form').serialize() and inspect it or count the number of inputs within the form, or post the values and inspect the HTTP message; most probably you will find that the browser is not sending the whole form for some reason.
The problem was fixed with the bagonyi's help.
In fact, I was using suhoin and I had to set in my php.ini:
[suhosin]
suhosin.request.max_vars = 10000
suhosin.post.max_vars = 10000
That resolved the problem.

PHP and (too) many input fields

I've got a html-form with roughly ~1500 input fields* (either text or hidden).
The form.action is POST and every inputfield has a unique name (no name=foo[]).
Whenever I try to print every variable of $_REQUEST in PHP after the form is submitted, only the first few entries are printed. In fact, the $_REQUEST variable only contains 1001 items (so about 500 fields are missing).
Any idea why this happens ?
Since data are sent via post not get, the url-limit is not a problem. So I thought that it had something todo with the config of the webserver and that the request was too big. But setting LimitRequestBody to 0 doesn't changed anything in the result.
In terms of memory used by this PHP-array I only read that the size is only limited by the overall memory, which should be more than enough. (keys are about 20chars each, and the value is about 6chars each)
Do I miss something?
*In case you wonder: the navigation consists of about 750 entries, 2 fields per entry (one position for ordering and one for parent if nested)
Since PHP 5.3.9 there's a new configuration setting called "max_input_vars" which limits the number of input variables. The default setting is 1000. Also check if Suhosin is installed, because there's also a similar setting.
Although, I would recommend to reduce the number of fields if possible.
Try to override php_flag max_input_vars.
Add to your .htaccess file or change php.ini
php_flag max_input_vars 1500
There is also a flag for nesting
php_flag max_input_nesting_level 64
Perhaps you exceed the size of a POST? yo could use mime multipart, like people do wen are posting files.
Check your php.ini configuration for the post_max_size value - perhaps you have exceeded it?

Text size limit on website

I am using a combination of ajax php and sql. I have a local copy of this program and a live sever run by a company, there is a button that posts a comment, on the local copy you can post a comment of any size, but on the live server I have narrowed it down to about 512 bytes once the comment gets larger than that, no error is generated but the comment isn't added, is there any configuration files concerning MySQL databases PHP or javascript that could limit the amount of data that can be parsed?
Ok there was a get max value paramater in php.ini (under the settings for shino or something like that that was on the live server) that was set to 512 I changed it so now the system can handle 10KB of text for comments
is the action of the form for posting comments GET or POST?
if it's POST: in the php.ini, there's a configuration called post_max_size (documentation), please take a look at that on your local- and production-server and compare the values.
if it's GET: some browsers limit the querystring to aroudn 2kb, so maybe you exceed this... you should use POST instead.
If it were me, I would probably use the "onSubmit" tag on the form an run a quick javascript validation on the input (a function called from onSubmit="return func(this)" will only transmit if func(this) returns true). Simply have it call a function, and if the value of the field has a string length and return a little alert window if there are more than 500 characters. That way you don't necessarily parse or transmit anything you don't have to.
You'll probably want to have a fallback so that someone with javascript disabled can't bypass those limits, but that should work for the majority of your users.

Categories