简体   繁体   中英

Submit button showing in GET URL

I'm having a problem with my HTML GET form that's connected to a PHP script, so, basically, when the action is done I see the SUBMIT button value in the URL, so it's like this http://url.com/?valueI=Want&submit=Submit+Value .

How do I stop that from happening?

Remove the name attribute from the submit element to prevent it from being passed in the query parameters.

See: Stop the 'submit' button value from being passed via GET?

This is the nature of GET requests. The submitted values, aka Query String, are shown as part of the URL after a ? suffixing the page URL.

If you don't want it to show up, use POST method, or make a script that submits using Ajax.

Now if the question is only about the text in the submit button being shown, if you don't want it to get submitted along with the rest of the form all you have to do is not give it a name.

<input type="submit" value="Send Form">

No name="..." in the tag.

you need to set the form method

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

您可以使用按钮标记使用GET方法提交值。

<button type="submit">Submit</button>

do something like:

<form action="myfile.php" method="get">
  (your form elements here)
  <input type="submit" value="Submit" />
</form>

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