HTML Form: How to submit many (100+) inputs

Multi tool use
Multi tool use
The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


HTML Form: How to submit many (100+) inputs



I am working on a system that allows the user to preview the result as an HTML table. I put a checkbox in the leftmost cell that is checked by default. Should the user uncheck any row, that row will not appear in the final product.



Submitting this form, which as of now is only these checkboxes, with just HTML yields a 404 error. Removing or significantly reducing the number of the checkboxes fixes this problem.



I implemented name = "checkbox" instead of name = "checkbox1", name = "checkbox2", ... to see if that would solve the problem; it didn't.


name = "checkbox"


name = "checkbox1", name = "checkbox2", ...



I also tried serializing and submitting the form data with jQuery post and PHP, which still gives me the 404. I tried submitting the form using AJAX and jQuery to the same effect.



I'm not sure if submitting the data through $_SESSION will help. I don't know how I would implement this in my use case.


$_SESSION



How can I submit many inputs without causing an error?



EDIT: A hopefully minimal, complete and verifiable example (using only HTML, since none of the scripting methods produced a better result):


<?
print "<form action = 'target.php' method='get'>";
for( $i = 0 ; $i < 200 ; $i++ ){
print '<input type="checkbox" name="chk" checked /> Checkbox ' . $i . '<br />';
}
print '<input type="submit" value="Submit">';
?>



This produces the same error for me: 404.





Which HTTP method are you using to send that payload to backend? And which request method is expecting your backend?
– Ele
yesterday







I have tried GET and POST
– Aditya J.
yesterday





Which endpoint is posted to for the both the 200 and 404 requests?
– Clint
yesterday





A 404 error indicates that the page you are submitting the data to doesn't exist. This will get triggered before any potential errors with your data itself. You're simply sending your data to the wrong page. Please add a minimal, complete, and verifiable example of your submission.
– Obsidian Age
yesterday







The client and backend should work with the same HTTP method, further, that amount of data must be sent using the HTTP POST method. Please post a Minimal, Complete, and Verifiable example
– Ele
yesterday




1 Answer
1



Replace <form action = 'target.php' method='get'> with <form action = 'target.php' method='post'>


<form action = 'target.php' method='get'>


<form action = 'target.php' method='post'>



You use the GET method, which means that the input names and values will be sent in the URL. If you send data to the server, always use POST.


GET


POST



If you have 100+ inputs, then the URL gets too long






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

EC lJTa,7LiWMxw,2F4RopiL6UqLt
NPZnKTW1dE,tTMaR

Popular posts from this blog

Keycloak server returning user_not_found error when user is already imported with LDAP

PHP parse/syntax errors; and how to solve them?

415 Unsupported Media Type while sending json file over REST Template