Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

$_SERVER['REQUEST_METHOD'] return GET insted POST

Tags:

post

php

get

I create a form using post method like that :

  <form name="indexFormn" id="indexForm"  method="POST" action="page.php">
  <div class="AdminformDiv">
  <div class="errorbox">
      <?php
      if (!is_array($this->actionErrors)) {
        echo $this->actionErrors;
    }
    ?>
</div>
<div>
    <table border="0" cellpadding="0" cellspacing="0" style="width:700px">
        <tbody>
            <tr>
                <td style="width:128px">Amount</td>
                <td colspan="2">$ <?php echo $this->price;?> USD<td     style="width:270px">&nbsp;</td>
            </tr>
            <tr>

.....

but the problem is when I do "var_dump($_SERVER['REQUEST_METHOD']);" in my php code I get all time "GET" not "POST" and really I don't know why?

like image 541
Jean Ter Avatar asked Oct 03 '22 04:10

Jean Ter


1 Answers

I just had this problem using Codeigniter's MVC Framework. Here's what I discovered:

My Action attribute in my form did not include the "www" in front of my domain, but my actual URL needed the "www".

i.e. my form had action="https://mydomain/something" but if I went to that URL, I noticed my web host added the www to the beginning: https://www.mydomain/something. (I use DreamHost and it's a setting that I had picked)

I hope this is your issue as well - really frustrating to try and figure out, but once I got my action and actual URL to agree on the "www", my request method went from GET to POST.

like image 188
Brian Stork Avatar answered Oct 07 '22 20:10

Brian Stork