user3124460
user3124460

Reputation: 15

PHP Search change the url of action

I am trying to create a search page where viewers can search through. Anyhow I have it all sorted but my search page is at "myurl.com/?p=search" although in my form [below] I have tried to put ?p=search as the action although after submitting the form I am faced with my url being
"myurl.com/?keyname=hey" instead of how its meant to be of "myurl.com/?p=search&keyname=hey"

<form action="?p=search" method="get">
  <label>Name:
  <input type="text" name="keyname" />
  </label>
  <input type="submit" value="Search" />
</form>

Any idea how I can change it?

Upvotes: 0

Views: 159

Answers (1)

1ace
1ace

Reputation: 5288

You need to add a hidden input field:

<input type="hidden" name="p" value="search" />

Or use the method POST so as to send your search query outside of the URL, leaving it untouched.

Upvotes: 4

Related Questions