问题描述
< form name =indexFormnid =indexForm method =POSTaction =page.php>
< div class =AdminformDiv>
< div class =errorbox>
<?php
if(!is_array($ this-> actionErrors)){
echo $ this-> actionErrors;
}
?>
< / div>
< div>
< tbody>
< tr>
< td style =width:128px>金额< / td>
< td colspan =2> $<?php echo $ this-> price;?> USD< td style =width:270px>& nbsp;< / td>
< / tr>
< tr>
.....
但问题是当我做的var_dump($ _ SERVER [ 'REQUEST_METHOD']);在我的PHP代码中,我得到所有的时间GET而不是POST,真的我不知道为什么?
解决方案基本上大多数HTTP请求都是GET请求。和$ _SERVER ['REQUEST_METHOD']计算默认的GET方法。
您可以使用if($ _ POST)来检查它是否为POST。 (这是带有POST数据的数组,所有页面都有$ _GET集合,所以如果($ _ GET)不能用来判断它是否为GET)
when你提交你的表单,那么你一定会在page.php上获得POST方法。
尝试在此页面上找到方法并找到。
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"> </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?
解决方案 Basically most HTTP requests are GET requests. and $_SERVER['REQUEST_METHOD'] evaluates default GET method.
you can use if($_POST) to check if it's a POST. (That's the array with POST data in it. All pages have $_GET set, so if($_GET) won't work to tell if it's a GET)
when you submit your form then you will sure get POST method on "page.php".try to get method on this page and found.
这篇关于$ _SERVER ['REQUEST_METHOD']返回GET insted POST的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
09-05 11:29
-
如何在C#.NET中使用OnPageIndexChanging来使用MySql
-
Node.js可以排队多少个事件?
-
如何使用Volley下载图像?
-
Python3中缺少Python 2的“ exceptions”模块,其内容去了哪里?
-
我无法获取客户端IP地址,而是在服务器上的运行时获取了本地IP地址
-
什么是打开一个TCP流服务器的最佳方法?
-
如何获得Windows 10周年更新的新Kinect驱动程序?
-
适用于Python 3.5.1的PyGObject?
-
网页抓取 - 他的应用程序已过期,请点击浏览器上的刷新按钮返回消息
-
ThreadPoolExcutor和invokeAll列表顺序
-
“未指定目标且未找到makefile。停止"。 ,构建android源代码时出错
-
无法打开源文件“unistd.h”
-
将Qt集成到预先编写的应用程序/框架中
-
了解从Cassandra中的单个分区读取
-
STL容器赋值和常量指针
查看更多