Text size limit on website - php

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.

Related

Submitting large amount of form data to PHP using POST

We are designing a system for conducting a survey in which it askes user a about 72 questions (Multiple Choice questions)
And when the user submits this will be posted to php page which will save the answer in a MySQL table.
Its works fine and perfectly well when we doing the test with a small number of user
But I observed the when a large amount of users are submitting not all data reaches the server only a part of some users answer (around 65 answer) only reaches the server.But i get data from my all users but some answers aren't compete.
Am using MySql engine : MyISAM
What would be the problem or how can i solve this. is it the problem with some php configuration or mysql (large number of insert statement)
What is the best way to handle larger amount data from a form submission php
Thanks in Advance
There is a limit on POST request size in PHP. You can adjust post_max_size in your php.ini. As for database, I don't know how you are saving them in the database, but there are character/storage limitation on the database as well.
Whenever I'm dealing with large POST data like sending numerous field values through forms, using ajax does wonders! Try using jQuery $.post(), which is the shorthand for $.ajax(). It's quite easy to use, even if you're not that familiar with jQuery :)
You need to Increase max_input_vars from php.ini OR you can set the following code in your .htaccess file.
php_value max_input_vars 3000
You should use the ajax function for post the data..
Go through bellow link,it might help you
https://www.w3schools.com/jquery/ajax_ajax.asp

What is the max lenght of a input text in php post request?

What is the max lenght of a input text in php post request ?
I need to post in a form symfony a very large json object in one input text but when the input is too large the data is from the input in the symfony controler is null.
I found some answers : set max_input_vars, max_upload_file in php.ini for change the apache configuration but it's does not work.
For example i have a input with value length = 4837112
So i'm asking if anyone know how disable the limit of the input text or set a biggest value to the limit ?
And if it's php or apache or maybe symfony which poses this problems ?
I can't comment yet because I don't have the rep to do so but I'll explain a few things. Also, please post some of your code, it would be very helpful.
When you POST something through PHP, the limit can be set in php.ini (or equivalent) and the httpd service must be restarted to take effect. If it's still not taking effect, then you have to take a few things into consideration.
Am I editing the correct values?
Do I have a non-standard installation like two versions of apache installed?
Do I have an override set somewhere else like htaccess or a setting in your framework?
Is the data REALLY sending?
You'll need to have something like firebug to help you debug this (click on console). If you see the data POST, have it return to you for debug purposes. If it doesn't come back but it does post, it could be one of the above or there's something wrong in your code.

Size of post too big

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.

What can cause $_POST data to be incomplete

I have a simple basic HTML form with about 1500 fields. 500 rows have text entries. When form is submitted, $_POST contains only about 130 entries of those 500 rows. post_max_size is high, so it's not that. You can see the barebone sample here:
http://www.dadilja.rs/test.php
If you check the source after submit, you will see that the $_POST data contains entries only until letter F.
So I'm figuring it's some server setting, since there's only HTML on the page, and the behaviour is the same on two different servers - probably some generic setting. If you check the Web console, and inspect Request Body, you will see that the form submits all the data. Any ideas?
Check your php.ini max_input_vars. Default is 1000.
Try to change the max_input_vars, check this as well for more info. Source - link.

Is there a limit on checked checkboxes in PHP form POST?

I've come across a problem, which I can't seem to fix. I have a form (method="post" enctype="multipart/form-data") in which the user can choose some options. They
have the possibility to 'check all'. If they 'check all', they are checking about
2000+ boxes. To check if my form actually gets posted, I have the following (not so complex) code:
<?php
if(isset($_POST['bijwerken'])) {
echo "YIPPEE!!";
}
?>
Now, if I check all the boxes, I don't get any feedback. If I only select like 20 boxes, I do actually get feedback. What am I missing? The checkboxes are also generated by a script, with an echo :
echo " <input type=\"checkbox\" name=\"productsoorten[]\" value='" . $rowproductsoorten1[productsoort1] . "'> " . $rowproductsoorten1[productsoort1] . "<br />";
Would love the hear some good ideas!
Yes, there's actually a max_input_vars setting. The default value is 1000 and your post inputs won't work if the number of input fields are more than that.
Edit your php.ini file (usually at /etc/php5/apache2/php.ini if you're on a Unix system) and increase the limit:
max_input_vars = 5000
If you can't modify the php.ini file, you can add this to .htaccess:
php_value max_input_vars 5000
I'm sure most people would choose simplicity over better design and I'm not going to explain every detail on how I'd handle this. If you don't understand what I'm talking or don't want to make the extra effort to write this pseudo-code out then this solution probably isn't for you.
I'd compress this data before you POST. First take the checkboxes out of your form tag so they don't get posted (we'll be giving it out own data).
Second, when the user submits the form (now with just a button) run some JS which traverses your DOM and gathers all of your check data. It will need to create a long array and then it'll need to use a separate long to shift the active bit if the checkbox is selected only (start at 1 and double the value for each checkbox until it reaches >2147483647). I would stop at 31bits per group (even though JS uses 64bit longs; the shift ops don't work above 32; also, JS doesn't have unsigned variables so unless you want to deal with flipping the - sign while all of this is going on then that's out too).
Third, post that to the server in a hidden text field and on the server end you get to reverse all of this.
Fourth, decode this on the server.
Fifth: Do this all again in reverse if you need the checks to begin correctly setup.
Advantages of This:
- MUCH less data travels between client and server
- No need to modify php.ini or even .htaccess
- This is able to grow and shrink dynamically (no need to reconfigure anything if you add another 2000 checks)
- Some browsers have limits on the number of bytes\fields you can post so simply increasing the number of fields won't always help.
- IE has limits on the length of a URL so forget about GET with the other solution. MAYBE, you can do it with this.
Disadvantages:
- Much more difficult to implement (nearly everything will need to be done 2 times for client and server as well)
- Users may not have JS enabled
- JS needs a lot of help when it comes to bit shifting
- Uses more CPU time
--
If you want to take this up a notch then you'll want to work out a fix for the JS bit shift operator problem (this will nearly halve your data length): Converting javascript Integer to Byte array and back
This improved version will also require a 64bit PHP installation on the server (or a BigInt class which is WAY out of scope for this question).

Categories