0

Regards. I want to send some of my values in the form by GET method and some by POST method. How can i do it ? Here is an example. I wan to make this kind of page, but i want a single submit button for both the forms. Is it possible to use GET method on some feilds and POST method on some ?

<html>

<form name="f2" action="a.php" method="POST">
       Name: <input type="text" name ="uname"/><br>
       Password: <input type="password" name ="pass"/><br>
       <input type="submit" >
</form>

<br><br>


<form name="f1" action="a.php" method="GET">
         Fav Movie: <input type="text" name="favmovie"><br>
         Movie rating:<input type="text" name="rating"><br>
         <input type="submit" value="My FAv movie">
</form> 



</html>
user1263375
  • 663
  • 3
  • 18
  • 35
  • 2
    see here http://stackoverflow.com/questions/2749406/post-and-get-at-the-same-time-in-php – PSR Mar 16 '13 at 08:49

4 Answers4

3

You cannot send the values of some input fields via GET and others via POST with PHP and HTML.

If you add JavaScript, you could add the values of some input fields to the query string of the action-attribute of the form. But this seems to be too much of a hassle.

Oswald
  • 31,254
  • 3
  • 43
  • 68
3

HttpRequests do not allow for multiple request types, however you could do

<form method="post" action="answer.php?foo=bar">
Pfft
  • 857
  • 6
  • 8
0

For same submit button -

It will be only possible if you start your form tag with conditional Programming.

i.e. after rendering from web server it will show only one form tag for a specific submit button.

Hope this helps you.

Piyas De
  • 1,786
  • 15
  • 27
0

The first question is, why would you want to do that?
I think the simple answer is no, a form can only be submit via one method, by get or post

Bryan Tung
  • 13
  • 4