Reputation: 1111
I have a form that submits the variable id
search.php?id=1
I have 2 defined variables that need to be added to this URL
search.php?id=1&definedvar=$definedvar&definedvar2=$definedvar2
I have tried adding a href to the button as a type button, this will only submit the defined variables
If the button is type submit it will only submit the id variable
how do I combine both?
Upvotes: 0
Views: 224
Reputation: 686
<form method="GET" action="search.php">
<input name="id" value="1" />
<input type="hidden" name="definedvar" value="<?php echo $definedvar; ?>" />
<input type="hidden" name="definedvar2" value="<?php echo $definedvar2; ?>" />
<input type="submit" value="Submit" />
</form>
Upvotes: 0
Reputation: 3867
You can add any number of hidden inputs
<input type="hidden" name="definedvar1" value="<?php echo $definedvar1;?>"/>
<input type="hidden" name="definedvar2" value="<?php echo $definedvar2;?>"/>
<input type="hidden" name="definedvar3" value="<?php echo $definedvar3;?>"/>
If your form is POST you can also pass any number of GET parameters in action
<form action="search.php?definedvar=<?php echo $definedvar1;?>&definedvar2=<?php echo $definedvar2;?>">
Upvotes: 1