WordPress.org

Ready to get started?Download WordPress

Forums

form not handling $_GET array variable (1 post)

  1. fedantiks
    Member
    Posted 5 years ago #

    I'm new to WP and PHP so there might be a few places where this goes wrong.. but I am trying to make a form where users can check the categories of posts that they want to see, then have only the intersection of their selections listed on the next page. I seem to have this form working..

    <form action="index.php" accept-charset="UTF-8" enctype="application/x-www-form-urlencoded" method="get">
    <input name="GeoIndSpec" size="20" type="checkbox" value="24" />Michigan</br>
    <input name="GeoIndSpec" size="20" type="checkbox" value="70" />Defense</br>
    <input name="GeoIndSpec" size="20" type="checkbox" value="66" />Automotive</br>
    <input size="20" type="submit" value="Search" />
    </form>

    but this only ends up putting the last item checked into the variable on the next page. I want to set "GeoIndSpec" as an array, but if I do this code

    <form action="index.php" accept-charset="UTF-8" enctype="application/x-www-form-urlencoded" method="get">
    <input name="GeoIndSpec[]" size="20" type="checkbox" value="24" />Michigan</br>
    <input name="GeoIndSpec[]" size="20" type="checkbox" value="70" />Defense</br>
    <input name="GeoIndSpec[]" size="20" type="checkbox" value="66" />Automotive</br>
    <input size="20" type="submit" value="Search" />
    </form>

    the URL comes back messed up: http://127.0.0.1/wordpress/index.php?GeoIndSpec%5B%5D=24

    I know that's the value for the left and right brackets, but I thought that's how one turned it into an array to handle multiple values? Any help would be greatly appreciated- thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic