|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-02-26 05:17 UTC] jroland at uow dot edu dot au
I am currently experincing some problems with missing post form data. There seem two be 2 problems: 1) When a variable is long (for example a textarea and lots of text is in it), the post data is not sent. 2) Sometimes even with small textarea, the post is still not outputed, but if you hit refresh and click reload post data, it sometimes works. I have also set the max post size to 20MB which should be plenty for just text. I seem to have this problems on all browsers / computers. Ay ideas? Thanks Joel PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 11:00:01 2025 UTC |
Hi, Don't know if it helps but I found out that informations about the file uploaded from a form using "multipart/form-data" like in the example below is not in the $_POST array but in the $_FILES array <form enctype="multipart/form-data" method="post" action="WinnyReader.php"> <input type="file" name="fWinnyFile" size="40" /> <input type="submit" value="Go" /> </form> After hitting the submit button, the second script (in my example, "WinnyReader.php") will look for informations about the file in $_FILES["fWinnyFile"] (and not in $_POST["fWinnyFile"] even if the method of the form is POST!!). That will do something like this: if (isset($_FILES["fWinnyFile"])) { $arWinnyFile = $_FILES["fWinnyFile"]; echo "name : " . $arWinnyFile["name"] . "<br />\n"; echo "type : " . $arWinnyFile["type"] . "<br />\n"; echo "tmp_name : " . $arWinnyFile["tmp_name"] . "<br />\n"; echo "error : " . $arWinnyFile["error"] . "<br />\n"; echo "size : " . $arWinnyFile["size"] . "<br />\n"; $stFilename = $arWinnyFile["tmp_name"]; } else { ... } Hope this helps! Vincent FINETI too am experiencing what has been described in the this submission. I think I have isolated it to php on windows. I summarize it thus because I have an xp, w2k3 and wme servers that experience the same problem. Yes I have used the latest version as of today 4.3.9 build date 7/30/04. I have scripts that have alot of post data, a table full of input objects, the table can be quite large. If I exceed a certain amount (I know it is not an arbitrary size, but I don't know what the size is, but I can duplicate it). Below are my scripts. <?php print '<html><head></head><body><form name = "pageform" action = "post.php" method = "post"><table>'; for ($l = 0; $l < 100; ++$l) { print "<tr><td>First Name</td><td><input type = \"text\", name = \"firstname[$l]\" /></td>\r\n"; print "<td>Last Name</td><td><input type = \"text\", name = \"lastname[$l]\" /></td>\r\n"; print "<td>City</td><td><input type = \"text\", name = \"city[$l]\" /></td>\r\n"; print "<td>State</td><td><input type = \"text\", name = \"state[$l]\" /></td></tr>\r\n"; } print '</table><input type = "submit" value = "submit"/></form></body></html>'; ?> This simply provides my form with a lot of input elements in my html. When submitted it will call the following script <?php print getenv('CONTENT_LENGTH'); print "$HTTP_RAW_POST_DATA<br>"; print_r($_POST); ?> Here is the output 6559 Array ( ) Now if I change my script (action = "cgi-bin\post.ext") to call the following c compiled script... #include <stdio.h> #include <stdlib.h> #include <string.h> main() { char *endptr; int i; double contentlength; char buff[10000]; char a,b; const char *len1 = getenv("CONTENT_LENGTH"); contentlength=strtol(len1, &endptr, 10); fread(buff, contentlength, 1, stdin); printf("Content-type: text/html\n\n%s",buff); } to do the same thing essentially I will get the following 5B95%5D=&lastname%5B95%5D=&city%5B95%5D=&state%5B95%5D=&firstname%5B96%5D=&lastname%5B96%5D=&city%5B96%5D=&state%5B96%5D=&firstname%5B97%5D=&lastname%5B97%5D=&city%5B97%5D=&state%5B97%5D=&firstname%5B98%5D=&lastname%5B98%5D=&city%5B98%5D=&state%5B98%5D=&firstname%5B99%5D=&lastname%5B99%5D=&city%5B99%5D=&state%5B99%5D= This is just a portion of the data that I get, it happens to be the last of the output do demonstrate that I do get the last of the input elements, notice city%5b99%5d, this is the 99th city element, the loop goes from 0-99. Now if you reduce the loop to be 0-5 for example (for ($l = 0; $l < 5; ++$l)) I get the following output when I use the first script (action = "post.php"). 309firstname%5B0%5D=&lastname%5B0%5D=&city%5B0%5D=&state%5B0%5D=&firstname%5B1%5D=&lastname%5B1%5D=&city%5B1%5D=&state%5B1%5D=&firstname%5B2%5D=&lastname%5B2%5D=&city%5B2%5D=&state%5B2%5D=&firstname%5B3%5D=&lastname%5B3%5D=&city%5B3%5D=&state%5B3%5D=&firstname%5B4%5D=&lastname%5B4%5D=&city%5B4%5D=&state%5B4%5D= Array ( [firstname] => Array ( [0] => [1] => [2] => [3] => [4] => ) [lastname] => Array ( [0] => [1] => [2] => [3] => [4] => ) [city] => Array ( [0] => [1] => [2] => [3] => [4] => ) [state] => Array ( [0] => [1] => [2] => [3] => [4] => ) ) The first part is the raw post data, the last is the $_POST variable. I did the c compiled script, simply to rule out my webserver (apache 1.3.27).After updating from 4.3.7 to 4.3.8 i'm loosing POST data. If i create a form with normal text fields and not to much input data there doesn't seem to be a problem. If i use <textarea> with a text larger 985 characters the post data is not send. Used this script to test: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> </head> <body> <form action="index.php" method="post"> <textarea name="text"></textarea> <input type="submit" </form> <? print_r($_POST); ?> </body> </html> if i add 'enctype="multipart/form-data"' to the form. All post data is send. php version : 4.3.8 os: OpenBSD 3.5-current apache: 1.3.29I have experienced this issue also. My environment is: - php 4.4.2 as a module - Apache 1.3 - Windows 2000 Server When I send a form with a text area using POST i don't receive any data. In my case, it was because I was sending de form using a Javascript code: function newitem(tipus) { var accion; if (tipus == 1) { accion = document.mailing.action="pre_mailingsmanuals.php"; } else { accion = document.mailing.action="env_mailingsmanuals.php"; } document.mailing.action=accion; document.mailing.submit(); } The input was specified as a button: <input type="button" onclick="newitem(1) ...>" instead of as a submit. Also, I was using a Rich Text Area. This issue doesn't occurs with a normal textarea. The form get working when I change the "button" for a "submit", without use javascript code for send it. I hope this message may be usefull for other users with the same problem. There is an official response from the PHP team from this issue ? RegardsJust came across the same problem myself last week. PHP 5.1.6 Apache 2.0.59 FreeBSD 6.1-RELEASE-p11 EVERY browser I have tried in Windows fails to work past a request size of about 1450 bytes. I have tested IE 6.0, FF 2.0.0.3 and Safari Beta 3. PHP still returns the requests size via getenv("CONTENT_LENGTH") but both $_POST and $_GET are empty. When I try the EXACT same page on the EXACT same server with both FF 2.0.0.3 and Safari 2.0.4(419.3) I have no problems submitting however much data I want. Here's my test form: /-------- CODE ---------/ <html><head><title>TEST</title></head> <body> <pre> <?php print_r($_POST); print_r($_GET); echo "Request Length: ".getenv("CONTENT_LENGTH"); ?> </pre> <form method="post" name="form" enctype="multipart/form-data" action="test.php"> <input type="file" name="file" /><br> <input type="text" name="field" value="<?php echo $_POST['field']; ?>" /><br> <textarea cols="80" rows="8" name="text"><?php echo $_POST['text']; ?></textarea><br> <input type="image" name="submit" src="images/addcart.gif" /><br> <input type="submit" name="submit-button" value="Real Submit Button" /> </form> </body></html> /-------- CODE ---------/ I get the same result with and without the enctype. I can't believe nobody has found a solution for this yet. If somebody has, please post it here or email me and I will.This post exists to try and organize what I've read above. There appear to be two main issues here. The special character issue in IE seems to be well understood at this point. The fix is to to translate all those characters into ascii (unicode html entities are helpful here). However, it appears that several people, including myself, still have a length problem. In my script, I have max_post_size set to 50M and output_buffering on (as suggested in these comments). I have an all-ascii piece of data, which works up to 10021 characters, but fails at 10022, regardless of what the last character is. This fails in all browsers: Safari, Firefox, and IE. The data is not accessible via $_POST or $HTTP_POST_VARS. It fails with or without enctype="multipart/form-data". getenv("CONTENT_LENGTH") is 10173 in Firefox and 10111 in Safari. If I change to a GET request, I receive an error indicating that the URI is too long for the server to support. My setup is: PHP 5.03 Apache 1.3.33 FreeBSD 4.10It appears I miscounted the length of my data in the above comment. Here is a test script that proves the maximum length, at least on this setup, is exactly 10,000 characters: <html> <body> <p> <?php echo "<strong>Request Length:</strong> " . getenv("CONTENT_LENGTH") . "<br />"; echo "<strong>POST:</strong> "; print_r($_POST); echo "<br />"; echo "<strong>HTTP_POST_VARS:</strong> "; print_r($HTTP_POST_VARS); ?> </p> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <textarea name="test" rows="50" cols="80"><?php for ($i = 0; $i < 10001; $i++) { echo 'a'; } ?></textarea> <input type="submit" /> </form> </body> </html>Hi, I am facing problem when submitting form in backend php to save form data in database so $_POST variable is showing empty. i am using latest version of php wamp server.pls suggest.due o this Undefined index error showing on the page. ( ! ) Notice: Undefined index: first_name in C:\wamp\www\FinalMyCourse\regdb.php on line 11 Call Stack # Time Memory Function Location 1 0.0006 397728 {main}( ) ..\regdb.php:0 ( ! ) Notice: Undefined index: first_name in C:\wamp\www\FinalMyCourse\regdb.php on line 29 Call Stack # Time Memory Function Location 1 0.0006 397728 {main}( ) ..\regdb.php:0 ArrayArrayArrayArrayAll fields are required. array 'middle_name' => array 0 => string 'hj' (length=2) 'last_name' => array 0 => string 'h' (length=1) 'ages' => string 'jhkjh' (length=5) 'mobileno' => array 0 => string '786987' (length=6) 'email' => array 0 => string 'hjkjh@qwe.com' (length=13) 'password' => string '' (length=0) 'password_confirmation' => string '' (length=0) 'timepass' => string 'Hindi' (length=5) 'address' => string '' (length=0) 'city' => string '' (length=0) 'skills' => string '' (length=0) 'totexp' => string '' (length=0) 'prefslot' => string 'Weekend' (length=7) 'preftiming' => string 'Morning' (length=7) 'regsubmit' => string 'Register' (length=8) ( ! ) Notice: Undefined index: first_name in C:\wamp\www\FinalMyCourse\regdb.php on line 47 Call Stack # Time Memory Function Location 1 0.0006 397728 {main}( ) ..\regdb.php:0 ( ! ) Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in C:\wamp\www\FinalMyCourse\regdb.php on line 48 Call Stack # Time Memory Function Location 1 0.0006 397728 {main}( ) ..\regdb.php:0 2 0.0045 406008 mysqli_real_escape_string ( ) ..\regdb.php:48 ( ! ) Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in C:\wamp\www\FinalMyCourse\regdb.php on line 49 Call Stack # Time Memory Function Location 1 0.0006 397728 {main}( ) ..\regdb.php:0 2 0.0047 406136 mysqli_real_escape_string ( ) ..\regdb.php:49 ( ! ) Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in C:\wamp\www\FinalMyCourse\regdb.php on line 50 Call Stack # Time Memory Function Location 1 0.0006 397728 {main}( ) ..\regdb.php:0 2 0.0048 406216 mysqli_real_escape_string ( ) ..\regdb.php:50