-1

I have a PHP file that has a form that is supposed to be sending 1060 entries (from 1060 textboxes) to a PHP file which will then add them in a database. But from the 711th textbox to the 1060th, it doesn't retrieve anything and sends me the Undefined index SQL error. The 1060 textboxes basically has the same codes except for some numbers are changed. Is there a limit on the number of textboxes that can be retrieved? If there is a limit, is there a way to increase it? (I am using WAMP/I am not using the GETmethod, only POST)

Part of the 1060 textboxes code This code is repeated 1,060 times on the same page only changing the number (db1, db2, etc.) It is also inside a form(<form></form>), has a SUBMITbutton and is basically complete.:

<?php
    $username=$_SESSION['username'];            
    echo "  <script type=text/javascript>
    var hidden = false;
    function actiondb143() {    
        if(!hidden) {   
            document.getElementById('clickdb143').style.visibility = 'visible'; 
            document.getElementById('db143').style.visibility = 'visible';  
            document.getElementById('db143').value = value='".$username."';         
        }                                   
    }                                       
    </script>   
    ";
    echo "</head>";
    echo "<body>";
    $country="Philippines";
    $curdate=$_SESSION["curdate"];
    $checker=mysqli_fetch_array(mysqli_query($con, "SELECT colDoneBy FROM tblChecklist WHERE colEntryID='143' AND colDate='$curdate' AND colCountry='$country'"));
    if($checker[0] != NULL){
        $result=mysqli_query($con,"SELECT * from tblChecklist WHERE colEntryID='143' AND colDate='$curdate'");
        while($row=mysqli_fetch_array($result))
        {
            echo "<center><table border=0 width=100><font face=arial>";             
            echo "<td width=100 bgcolor=#844BA13>";
            echo "<input type=text name=db143 value=".$row["colDoneBy"]." size=12 readonly>";
            echo "</td>";
            echo "</font></table></center>";                        
        }       
    }
    else {
        echo "<table border=0 width=100><font face=arial>";
        echo "<td width=100 bgcolor=#C44448>";
        echo "<div class=buttonasglobal><input type=button value='   VERIFY   'name=clickdb143 onClick='actiondb143()'; style=\"left:100;\"></div>";
        echo "<div class=textasglobal><input type=text name=db143 style=\"visibility:hidden; width:80px;\" readonly>";
        echo "</td>";
        echo "</font></table>";
    }
?>

Parts the PHP code that adds the data in the database(Again, repeats 1,060 times, only changing by number):

<html>
 <head>
    <title>Jobsheets+</title>
        <script type=text/javascript>
        function getDate(){
            document.getElementById('curdate').value =new Date().toLocaleDateString();
        }

    </script>
    </head>
    <body onLoad = 'getDate();' background="bgimage.jpg">
        <?php
            session_start();            
            $con=mysqli_connect("localhost","root","","dbjobsheets");
            if (mysqli_connect_errno($con))
            {
                echo "Failed to connect to MySQL " . mysqli_connect_error();
            }           
            $curdate=$_SESSION["curdate"];      
            mysqli_query($con,"UPDATE tblChecklist SET colActualStart='$_POST[as143]', colActualEnd='$_POST[ad143]', colRemarks='$_POST[jr143]', colDoneBy='$_POST[db143]', colCheckedBy='$_POST[cb143]' WHERE colEntryID='143' AND colDate='$curdate'");
            mysqli_close($con);
        ?>
    </body>
</html>
Ruther Melchor
  • 69
  • 2
  • 10
  • I don't see your form tag, but if you use the method GET then you should know about the limitations of the GET method, see http://stackoverflow.com/questions/2659952/maximum-length-of-http-get-request – VMai Sep 04 '14 at 06:40
  • The entirety of the the sample code is inside a form that is why I can retrieve textboxes 1 to 710. I'm not using any `GET` command, only `POST` as indicated in the sample PHP code. But if the `GET`function has its limits, maybe `POST` does too. Is there a way to configure the WAMP server to increase it the limit? – Ruther Melchor Sep 04 '14 at 06:47
  • Your first part is missing the form tag. That's bad. In your second script you should use var_dump($_POST) to see, what's in the request. I recommend to use parameterized prepared statements instead of the concatenation of sql statements with unsanitized user input. A single single quote will break this. – VMai Sep 04 '14 at 06:56
  • Your first part is using the same name for every textbox too. This code seems far from that you're really using. – VMai Sep 04 '14 at 06:59
  • First of all, is it said in the first edition of my question that it was only a ***Part*** of the code; I can't post the entirety of my code because as of now it has over 50K lines of code (Mostly consisted of repeated codes that has minimal difference but on their on own, essential to the system). Secondly, why would I lie and post a module that I want fixed if it's a module that I'm not using. This is the problem with SO, junior programmers are being shot down with downvotes due to technicalities instead of leading them in the right way/answering the question. – Ruther Melchor Sep 05 '14 at 01:34

1 Answers1

1

Important parts of your source are missing, so i can guess only.

I you are doing a GET with those 1000+ inputboxs i it possible that you blast then max. url length. Some firewalls, proxy's and webservers limit the url to 1024 bytes.

You form should do a POST, then the data ins transfer in the body and is limited only by max_post_size in PHP.

Your code contains an SQL-INJECTION. Use parameters instead of creating a SQL on the fly.

The PHP people introduced a limit with that hash-collision bug.

max_input_vars

Maybe this also plays here.

coding Bott
  • 4,287
  • 1
  • 27
  • 44
  • I've read about that and modified my php.ini using my Wamp Icon and increased the following codes `max_post_size` and `max_input_vars`;it still doesn't solve the problem though. – Ruther Melchor Sep 04 '14 at 09:48
  • On windows you often need to restart services. Did you do that for the webserver? – coding Bott Sep 04 '14 at 12:01
  • I had WAMP services restarted; did not fixed it. Restarting the PC solved it. Increasing `max_input_vars`, `post_max_size`, & `memory_limit` solved it. Thank you for directing me in the right idea/solution. – Ruther Melchor Sep 05 '14 at 01:29