Thomas
Thomas

Reputation: 57

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?

Upvotes: 0

Views: 3602

Answers (5)

Alfred
Alfred

Reputation: 21396

do something like:

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

Upvotes: 0

ray2orion
ray2orion

Reputation: 81

You can use button tag to submit the value using GET method.

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

Upvotes: 0

Havenard
Havenard

Reputation: 27854

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.

Upvotes: 2

tkocmathla
tkocmathla

Reputation: 911

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?

Upvotes: 2

Fiambre
Fiambre

Reputation: 1979

you need to set the form method

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

Upvotes: 0

Related Questions