0

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?

2 Answers 2

1

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;?>">
Sign up to request clarification or add additional context in comments.

Comments

0
<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>

3 Comments

you should be hidding those <input>. It is not good to show them.
o yes, input 'definedvar" and "definedvar2" should be type="hidden" too.
So could you please add it to your answer, so that it will be fully correct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.