# $\_SERVER\['REQUEST\_METHOD'\] always "GET"

**URL:** https://boards.straightdope.com/t/_server-request_method-always-get/603484
**Category:** Factual Questions
**Created:** [November 19, 2011, 8:52pm UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484 "2011-11-19T20:52:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![fumster](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@fumster](https://boards.straightdope.com/u/fumster)
#### Post date: [November 19, 2011, 8:52pm UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/1 "2011-11-19T20:52:00Z")

</div>

I have Googled and not figured this out, I am sure it’s something stupid. I am always getting “get” back from $\_SERVER[‘REQUEST\_METHOD’] even if the form method is “post”. Any help would be appreciated.

---

<div class="post-metadata">

### Author: ![tellyworth](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tellyworth](https://boards.straightdope.com/u/tellyworth)
#### Post date: [November 19, 2011, 10:28pm UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/2 "2011-11-19T22:28:03Z")

</div>

Most likely explanation: your form markup is wrong, and the $\_SERVER value is in fact correct. Start by validating your markup at [http://validator.w3.org/](http://validator.w3.org/). If it validates and you’re still having trouble, pastebin your markup so we can take a look.

---

<div class="post-metadata">

### Author: ![fumster](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@fumster](https://boards.straightdope.com/u/fumster)
#### Post date: [November 20, 2011, 1:56am UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/3 "2011-11-20T01:56:44Z")

</div>

> [@tellyworth](#):
>
> Most likely explanation: your form markup is wrong, and the $\_SERVER value is in fact correct. Start by validating your markup at [http://validator.w3.org/](http://validator.w3.org/). If it validates and you’re still having trouble, pastebin your markup so we can take a look.

Thanks, that is a great tool. I cleaned up a couple of warnings and it works now.

---

<div class="post-metadata">

### Author: ![fumster](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@fumster](https://boards.straightdope.com/u/fumster)
#### Post date: [November 20, 2011, 2:31am UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/4 "2011-11-20T02:31:09Z")

</div>

Well not so fast. Post seemed to work a few times then stopped. Here is my markup:

```auto

<!DOCTYPE html>
<html lang="en-US">

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Test Forms</title>
</head>

<body>

	<form method="GET" name="getform" action="http://xxx.com/xxx/split.php">
		<input type="submit" value="Test Get" />
	</form>

	<br>
	<form method="POST" name="postform" action="http://xxx.com/xxx/split.php">
		<input type="submit" value="Test POST" />
	</form>
	
	
</body>
</html>

```

---

<div class="post-metadata">

### Author: ![fubbleskag](https://avatars.discourse-cdn.com/v4/letter/f/c2a13f/32.png) [@fubbleskag](https://boards.straightdope.com/u/fubbleskag)
#### Post date: [November 20, 2011, 4:29am UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/5 "2011-11-20T04:29:46Z")

</div>

if I add a simple

```auto

<?php echo $_SERVER['REQUEST_METHOD']; ?>

```

to your markup, I get the proper result for both a GET and a POST, respectively.

---

<div class="post-metadata">

### Author: ![fumster](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@fumster](https://boards.straightdope.com/u/fumster)
#### Post date: [November 20, 2011, 4:38am UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/6 "2011-11-20T04:38:11Z")

</div>

I think it’s a problem on my server, another server worked fine.

---

<div class="post-metadata">

### Author: ![tellyworth](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tellyworth](https://boards.straightdope.com/u/tellyworth)
#### Post date: [November 20, 2011, 4:38am UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/7 "2011-11-20T04:38:33Z")

</div>

Chances are it’s working, and your diagnostic is wrong.

```auto

<?php var_dump($_POST, $_GET, $_SERVER); >?

```

will probably be enlightening.

Also, if you’re not already using something similar, [getfirebug.com](http://getfirebug.com).

---

<div class="post-metadata">

### Author: ![fumster](https://avatars.discourse-cdn.com/v4/letter/f/e9c0ed/32.png) [@fumster](https://boards.straightdope.com/u/fumster)
#### Post date: [November 20, 2011, 6:12am UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/8 "2011-11-20T06:12:59Z")

</div>

It looks like it was because I was using a full URL for the ‘action=…’

---

<div class="post-metadata">

### Author: ![tellyworth](https://avatars.discourse-cdn.com/v4/letter/t/977dab/32.png) [@tellyworth](https://boards.straightdope.com/u/tellyworth)
#### Post date: [November 20, 2011, 10:07am UTC](https://boards.straightdope.com/t/_server-request_method-always-get/603484/9 "2011-11-20T10:07:47Z")

</div>

> [@sh1bu1](#):
>
> It looks like it was because I was using a full URL for the ‘action=…’

That’s not the cause. You have two symptoms: REQUEST\_METHOD is sometimes not what you expect; and putting a full URL in the action attribute alters behaviour. I don’t know why, but changing the action hasn’t fixed it, just masked some other problem.
