1

When clicking a button, I would like my URL to become this:

users.php?action=search&formvar1=value&formvar2=value&...

This is what I've tried:

<form id="search" action="users.php?action=search" method="get">

But this doesn't seem to work (it doesn't add the action=search part). Is there any way to do this? I know it works when using POST instead of GET, so why wouldn't it here?

Thank you

2 Answers 2

6

You can do that similarly to a POST form. Simply include the default attribute as hidden form field:

<form id="search" action="users.php" method="get">
<input type="hidden" name="action" value="search">

This way it will be added as parameter to the URL like all other variables.

Sign up to request clarification or add additional context in comments.

Comments

1

The browser is building the query string from scratch.

Instead, you can add an <input type="hidden" name="action" value="search" />.

Comments

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.