I have a HTML form that has 20 checkboxes in it and I’m using the isset() function from PHP to check whether or not each box was checked upon submission.
I would like the PHP script to add a $_GET variable to the URL for each checkbox that is checked.
For example, if checkbox #1 and #3 were checked, I want a header() function to redirect the user to http://domain.com/form.php?one=checked&three=checked but if #4, #7, and #19 were checked, I’d like the redirected URL to be http://domain.com/form.php?four=checked&seven=checked&nineteen=checked
Is this possible or is there a better way to do this?
P.S. This is for an advanced search feature to filter out results based on what boxes are checked
Create an array that maps checkbox numbers to parameter names, then iterate over the checked boxes and build a query string.