Search code examples
phpjqueryformsget

Create query string from specific input values with a button, ignoring others


I have a large calculator built as a form. I need to create a query string from 17 of the 150 inputs on the page, for the user to share. I'm using php to fill the inputs from the URL string. When using the form method GET, it creates the url with ALL the inputs, more than the character limit, when I only need 17 inputs. What is a good way to specify inputs by name to build the query string while ignoring others. I can't edit anything but the input's names. PHP or jQuery are already used on the page but I am very amature at them. Thanks for reading, while I continue to research.


Solution

  • Instead of using method='GET' on your form you can try method='POST'. According to What is the size limit of a post request? POST requests can be quite large depending on the server configuration.

    The only difference this will make to your PHP code is replacing $_GET with $_POST when accessing form control values.

    $val = $_POST['inputnamehere'];
    

    Heres the PHP $_Post documentation for ease.

    I hope I answered your question correctly! Good luck!