The Cache: Technology Expert's Forum
Welcome, Guest. Please login or register. September 21, 2019, 05:54:58 AM

Login with username, password and session length

Pages: [1]
Author Topic: Strange issue with POSTing large amounts of form data  (Read 3275 times)
Offline Offline

Posts: 17

View Profile
« on: November 29, 2008, 11:04:41 PM »

I'm writing a basic script to make writing lots of PPC ads easier. For reference, it looks like this right now:

echo "<form method='POST' action=''>";
foreach($dbh->getAllAdgroups() as $adgrpName) {
foreach($dbh->getAdDataByAdgroup($adgrpName) as $adData) {
echo '<h3>'.$adgrpName.'</h3>';
echo '<input type="text" size="35" maxlength="40" name="'.'headline-'.$adData['ad_id'].'" value="'.$adData['headline'].'"><br />';
echo '<input type="text" size="35" maxlength="40" name="'.'line1-'.$adData['ad_id'].'" value="'.$adData['line1'].'"><br />';
echo '<input type="text" size="35" maxlength="40" name="'.'line2-'.$adData['ad_id'].'" value="'.$adData['line2'].'">';
echo "<br /><br /><input type='submit' name='edit' value='Edit Ads' />";
echo "</form>";

Basically, the code spits out a bunch of textfields (headline, etc. of each ad), then I edit them in my browser and hit submit. The script also has a function which then takes the posted form data and then updates the database.

I've run into a strange issue where the POST works fine with small amounts (maybe up to 10-15 ads). But once a large amount of ads are being edited, the POST data is the same as when the script is first loaded (irregardless of what I change in the textfields).

I've been using var_dump to view the POST data, and it simply does not change when a lot of textfields are present.

Here's what I've tried so far to fix the issue:
- Increasing php.ini's post_max_size - no effect
- Tried POSTing to an external script instead of to itself - no effect
- Initially I had been using PEAR's HTML_QuickForm2, I switched to the code above, and the POSTs still don't work.
- Thought it might be a browser specific issue, so switched from Firefox 3 to IE 6, no effect.

I've even sniffed the headers, and the POST data changes are being transmitted fine in the header, yet they simply do not show that when I var_dump($_POST).

I have no idea what is causing this. The script works perfectly if the amount of POST data is low, I've used it successfully with 15-20 ads. When I run it with 80+ ads, no good. I should mention that I am running this script on localhost.

Any ideas or suggestions on what to try next would be greatly appreciated. Smiley

No links in signatures please
Olde World Hacker
Offline Offline

Posts: 10096

View Profile
« Reply #1 on: November 30, 2008, 12:21:31 PM »

Is this to one of your own servers, or someone else's? There's an Apache directive, I think it's post_body_maximum_size or something that will limit the size of a post before it even gets to PHP.

Other than that, I think the default maximum POST body size is like 2M (except when you MIME up a file). Just how big are you trying to push up?

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Offline Offline

Posts: 17

View Profile
« Reply #2 on: November 30, 2008, 09:40:22 PM »

Hi perkiset,

Good call about the Apache.

I am currently running a local WAMP install of Apache 2.2.6. I looked into the directives you mentioned and found this very useful link:

I originally thought the problem was with LimitRequestFields, but I can POST over 100 fields successfully. I think the problem is with LimitRequestFieldSize (which defaults to 8190 bytes), as I've noticed that I can POST successfully up to around 8000 bytes...


Never mind... just realized that it was a bug with my database structure.  D'oh!

I had duplicate rows in the table it was reading from, so what was happening was request parameters were being posted twice, so it looked like nothing was changing. I was using break statements when I was limiting the number of ads edited at each time, so the bug didn't appear then as the duplicates were not output. I've added a UNIQUE key to the table and it won't happen again.

Everything is working perfectly now. Thanks for the help perkiset - learned a good bit about limiting Apache requests sizes. Smiley

No links in signatures please
Pages: [1]
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks

Valid XHTML 1.0! Valid CSS!