0

I'm doing a project and using PHP. There is signup.php page with form and it is sending "GET" instead of "POST". Even after hours of debugging, I could not come up with anything, I found a similar question but that seems to be of no help in my case. I have similar login.php page with almost same code and that works fine, I don't know what wrong I'm doing.

<form name="signUpForm" id="signUpForm" action="signup.php" method="post">
    //form elements
    <button type="submit" value="Submit">Submit</button>
</form>

Following the question mentioned, I tried to change it to

<button type="submit" value="Submit" formmethod="POST" formaction="signup.php" >Submit</button>

But this also gives the same result.

echo $_SERVER["REQUEST_METHOD"];

Above statement prints "GET" in PHP.

I would like to know what I'm missing, I know similar questions exist but I checked them before putting the question.

Community
  • 1
  • 1
Saurabh Singh
  • 381
  • 5
  • 15
  • @nogad nothing changed, I already tried it, anyways Thank you – Saurabh Singh Jan 15 '17 at 19:56
  • `var_dump($_POST);` is that populated? are you dong any server side redirecting? –  Jan 15 '17 at 19:57
  • @nogad it says "array(0) { }"..redirecting only after successful insertion in database..but it is sending "GET" so I'm not able to read data to process – Saurabh Singh Jan 15 '17 at 20:01
  • last guess .. no other form on the page? is the url public? –  Jan 15 '17 at 20:13
  • @nogad Public?as is?..I did'nt get you..form is submitting to itself you can have a look https://ideone.com/f93owG .. I have a similar login page https://ideone.com/w7feHQ which works just fine – Saurabh Singh Jan 15 '17 at 20:17
  • 1
    the post works, the form then is redirected using your header call, on both success or **error**. you can see this with: `if ($_SERVER["REQUEST_METHOD"] == "POST") { exit('post');` –  Jan 15 '17 at 20:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/133223/discussion-between-100rabh-and-nogad). – Saurabh Singh Jan 15 '17 at 20:39

1 Answers1

0

GET is the automatic default. Make sure that you close all of your open form tags and set the method="POST".
I just ran into this problem!

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Jordan Casey
  • 955
  • 9
  • 16