How can I use GET and POST method in same <form>? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How can I use GET and POST method in same <form>?

What to do? When I want username to be in GET and Password in POST method be get in same <form> is this possible in HTML. Hey there! Anyone please help me with this🙏

20th Sep 2020, 7:11 AM
Hanumanthu Lakshmana Rao
Hanumanthu Lakshmana Rao - avatar
3 Answers
+ 2
Maybe you can technically, but you should not. A HTTP request should use a single method only. https://stackoverflow.com/questions/15447346/use-get-and-post-in-the-same-form
20th Sep 2020, 7:31 AM
Tibor Santa
Tibor Santa - avatar
0
You can pass the query to the page you want to set action to . like action="index.php?id=1"
20th Sep 2020, 7:13 AM
Hima
Hima - avatar
0
In my test a solution as follows works: xhr.open("POST", "postodp.php?username"); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("username="+escape(username));
20th Sep 2020, 7:50 AM
JaScript
JaScript - avatar