Question

I wanted to make a search form with GET but there seems to be a problem. The page you are looking at has other GET values too but it seems that the GET method clears the URL from variabels en goes like "?q=SEARCH" instead of "?p=Test&u=Bart&q=SEARCH".

This is the form code I'm using:

<form method="GET" action="test.php?p=glistentries&maingroup=<? echo $MainGroupID ?>&subgroup=<? echo $SubGroupID ?>">
                       <input type="text" class="form-control" id="focusedinput" value="<? echo $_GET['q']; ?>"
                       name="q" autocomplete="off" class="col-sm-4 control-label" placeholder="Search...">
                       <input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
                       </form>

Solved It Thanks guys, forgot I can simply do this with hidden fields

Was it helpful?

Solution

Add the additional GET vars as hidden inputs:

<input type="hidden" name="p" value="Test">

OTHER TIPS

Use input type hidden :

<form method="GET" action="test.php">
    <input type="text" class="form-control" id="focusedinput" value="<? echo $_GET['q']; ?>" name="q" autocomplete="off" class="col-sm-4 control-label" placeholder="Search...">
    <input type="submit" style="position: absolute; left: -9999px; width: 1px; height: 1px;"/>
    <input type="hidden" name="p" value="glistentries" />
    <input type="hidden" name="maingroup" value="<? echo $MainGroupID ?>" />
    <input type="hidden" name="subgroup" value="<? echo $SubGroupID ?>" />
</form>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top