johnnietheblack
johnnietheblack

Reputation: 13320

PHP form submit button in $_GET

I have a form that submits a search for blogs on my site via GET.

The form works fine, but when submitted, the url on the following page reads ("Find it" is the value of my submit button):

www.example.com/search.php?sub_q=Find+it%21&q=tennis

This just isn't an aesthetically pleasing url. Is there a simple way to exclude the submit button from the URL? I would like the url to look like:

www.example.com/search.php?q=tennis

The search.php doesn't require $_GET['sub_q'] to operate, btw.

Upvotes: 1

Views: 2059

Answers (2)

chelmertz
chelmertz

Reputation: 20601

See my answer here: SEO/PHP: How to Convert Form-Submit URL (Get-Method) without Javascript SEO-Friendly?

Basically: redirect to an easier-to-spell-out-URI

Upvotes: -2

Marek Karbarz
Marek Karbarz

Reputation: 29304

Try not naming your button (remove the name attribute) - it shouldn't be submitted if it doesn't have n name

Upvotes: 11

Related Questions