简体   繁体   中英

URL not changing after submitting a form

I have a form which looks like this:

<form action="" method="post">
...
</form>

When I click submit in it, I expect it to refresh the URL with the values submitted in the form. But it doesn't. The problem is that the submission depends on the url parameters.

Here is the problematic page:

http://www.comehike.com/hikes/search_hikes.php?all=yes&when=f&redirect=yes

If you search the top-left form it will not actually search what you asked because the URL isn't changing. It just searches the default values. Is there any way to remedy this? Where am I going wrong?

Thanks!

The action contains a relative URI pointing to the current URI and the method says to post the data (so it wouldn't appear in the query string). So you are getting the expected behaviour.

It sounds like what you want is actually:

<form action="search_hikes.php" method="get">

Shouldn't your post be a get if you want it to send the form values via the querystring?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM