php文件无法得到POST过来的数据,为什么-问答-阿里云开发者社区-阿里云

开发者社区> 问答> 正文

php文件无法得到POST过来的数据,为什么

2016-06-14 15:42:14 2808 1

php文件无法得到POST过来的数据,通过$_SERVER得到如下

Array
(
    [HOSTNAME] => localhost.localdomain  
    [PATH] => /usr/local/bin:/usr/bin:/bin  
    [TMP] => /tmp  
    [TMPDIR] => /tmp  
    [TEMP] => /tmp  
    [OSTYPE] =>   
    [MACHTYPE] =>   
    [MALLOC_CHECK_] => 2  
    [USER] => www  
    [HOME] => /home/www  
    [FCGI_ROLE] => RESPONDER  
    [GATEWAY_INTERFACE] => CGI/1.1  
    [SERVER_SOFTWARE] => nginx  
    [QUERY_STRING] =>   
    [REQUEST_METHOD] => GET  
    [CONTENT_TYPE] =>   
    [CONTENT_LENGTH] =>   
    [SCRIPT_FILENAME] => /data0/htdocs/www_v2/index/htdocs/index.php  
    [SCRIPT_NAME] => /index.php  
    [REQUEST_URI] => /tcenter/manage_type/saveunitc/  
    [DOCUMENT_URI] => /index.php  
    [DOCUMENT_ROOT] => /data0/htdocs/www_v2/index/htdocs  
    [SERVER_PROTOCOL] => HTTP/1.1  
    [REMOTE_ADDR] => 222.130.133.84  
    [REMOTE_PORT] => 11347  
    [SERVER_ADDR] => 118.145.8.49  
    [SERVER_PORT] => 80  
    [SERVER_NAME] => *.izton.com  
    [REDIRECT_STATUS] => 200  
    [HTTP_HOST] => www.izton.com  
    [HTTP_CONNECTION] => keep-alive  
    [HTTP_CACHE_CONTROL] => max-age=0  
    [HTTP_ACCEPT] =>   text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31   (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31  
    [HTTP_REFERER] => http://www.izton.com/tcenter/manage_type/editunit.do?id=11016502&num=2  
    [HTTP_ACCEPT_ENCODING] => gzip,deflate,sdch  
    [HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.8  
    [HTTP_ACCEPT_CHARSET] => GBK,utf-8;q=0.7,*;q=0.3  
    [HTTP_COOKIE] => PHPSESSID=8bc85489738f33e8909973ab534d7c80; KF360_6971_LIVE=Y; KF360_6971_REFERER=; PHPSESSID=ecb96ff35d7e68bdc14ffcfcd12835dc; KF360_6971_INVITEDTIMES=2; KF360_6971_VISITID=5666977; uname=172474; upass=123456; rem=1; Hm_lvt_b63d9415462f064e5fda5749bda4808f=1369358159; Hm_lpvt_b63d9415462f064e5fda5749bda4808f=1369641967; formhash=03bc8587; VISITORID=5269925  
    [PHP_SELF] => /index.php  
    [REQUEST_TIME] => 1369640508  
    [argv] => Array
        (
        )

    [argc] => 0  
)

但是在做项目的时候其他模板post的数据都可以接受,打印其中一个可接受到post数据的$_server

Array  
(  
    [HOSTNAME] => localhost.localdomain  
    [PATH] => /usr/local/bin:/usr/bin:/bin  
    [TMP] => /tmp  
    [TMPDIR] => /tmp  
    [TEMP] => /tmp  
    [OSTYPE] =>   
    [MACHTYPE] =>   
    [MALLOC_CHECK_] => 2  
    [USER] => www  
    [HOME] => /home/www  
    [FCGI_ROLE] => RESPONDER  
    [GATEWAY_INTERFACE] => CGI/1.1  
    [SERVER_SOFTWARE] => nginx  
    [QUERY_STRING] =>   
    [REQUEST_METHOD] => POST  
    [CONTENT_TYPE] => application/x-www-form-urlencoded  
    [CONTENT_LENGTH] => 199  
    [SCRIPT_FILENAME] => /data0/htdocs/www_v2/index/htdocs/index.php  
    [SCRIPT_NAME] => /index.php  
    [REQUEST_URI] => /tcenter/manage_type/saveUnit.do  
    [DOCUMENT_URI] => /index.php  
    [DOCUMENT_ROOT] => /data0/htdocs/www_v2/index/htdocs  
    [SERVER_PROTOCOL] => HTTP/1.1  
    [REMOTE_ADDR] => 222.130.133.84  
    [REMOTE_PORT] => 10758  
    [SERVER_ADDR] => 118.145.8.49  
    [SERVER_PORT] => 80  
    [SERVER_NAME] => *.izton.com  
    [REDIRECT_STATUS] => 200  
    [HTTP_HOST] => www.izton.com  
    [HTTP_CONNECTION] => keep-alive  
    [HTTP_CONTENT_LENGTH] => 199  
    [HTTP_CACHE_CONTROL] => max-age=0  
    [HTTP_ACCEPT] =>   text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8  
    [HTTP_ORIGIN] => http://www.izton.com  
    [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31  
    [HTTP_CONTENT_TYPE] => application/x-www-form-urlencoded  
    [HTTP_REFERER] => http://www.izton.com/tcenter/manage_type/addUnit.do?gid=0&did=0&sid=0&tid=0  
    [HTTP_ACCEPT_ENCODING] => gzip,deflate,sdch  
    [HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.8  
    [HTTP_ACCEPT_CHARSET] => GBK,utf-8;q=0.7,*;q=0.3  
    [HTTP_COOKIE] => PHPSESSID=8bc85489738f33e8909973ab534d7c80; KF360_6971_LIVE=Y; KF360_6971_REFERER=;   PHPSESSID=ecb96ff35d7e68bdc14ffcfcd12835dc; KF360_6971_INVITEDTIMES=2; KF360_6971_VISITID=5666977; uname=172474; upass=123456; rem=1; Hm_lvt_b63d9415462f064e5fda5749bda4808f=1369358159; Hm_lpvt_b63d9415462f064e5fda5749bda4808f=1369641967; formhash=03bc8587; VISITORID=5269925  
    [PHP_SELF] => /index.php  
    [REQUEST_TIME] => 1369640436  
    [argv] => Array  
        (  
        )  

    [argc] => 0  
)    

两者的不同之处 ‘HTTPCONTENTTYPE’与‘HTTPCONNECTION’,‘HTTPCACHE_CONTROL’,

模板来回看了n遍,也没找到错误 下面是无法post数据的模板

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
        <title></title>
        <script type="text/javascript" src="<!--{$baseurl}-->/js/jquery.js"></script>
    </head>
    <body>
        <div class="nav3 mb10"  >
            <ul class="cc" style="margin-left:20px;margin-top: 10px">
                <li><a href="/tcenter/manage_type/manageunit.do">管理单元</a></li>                 
            </ul>
        </div>
        <form action="/tcenter/manage_type/saveunitc"  method="post" onsubmit="return check();">
            <input type="hidden" name="id" value="<!--{$mesunit.id}-->" />
            <table style="width:300px;">
                <tr>              
                    <td>单元顺序:</td>
                    <td>
                        <select name="unitnum" id="unitnum" >
                            <option value="0" >请选择</option>
<!--{foreach from=$unitnums key=key item=item}-->
                            <option value="<!--{$key}-->" <!--{if $key==$num}-->selected<!--{/if}-->><!--{$item}--></option>
                            <!--{/foreach}-->
                        </select>          
                    </td>
                </tr>      
                <tr>
                    <td>单元名称:</td> 
                    <td><input type="text" name="name" id="name" value="123"/></td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="submit" value="提交" class="inputs"/>
                    </td>            
                </tr>
            </table>
        </form>       
    </body>
</html>
取消 提交回答
全部回答(1)
  • 落地花开啦
    2019-07-17 19:37:54

    感觉是个低级错误,你上边打出来的$server 里method 是GET ,提交get请求肯定没有
    $POST了 “ [REQUEST_METHOD] => GET”

    0 0
相关问答

170

回答

惊喜翻倍:免费ECS+免费环境配置~!(ECS免费体验6个月活动3月31日结束)

豆妹 2014-10-29 17:52:21 234071浏览量 回答数 170

145

回答

【新手入门】云服务器linux使用手册

fanyue88888 2012-11-26 17:14:18 160084浏览量 回答数 145

22

回答

爬虫数据管理【问答合集】

我是管理员 2018-08-10 16:37:41 149037浏览量 回答数 22

24

回答

阿里云开放端口权限

xcxx 2016-07-20 15:03:33 660880浏览量 回答数 24

31

回答

[@倚贤][¥20]刚学完html/css/js的新手学习servlet、jsp需要注意哪些问题?

弗洛伊德6 2018-10-27 21:52:43 148183浏览量 回答数 31

34

回答

Win Server 2003-2016 加密勒索事件必打补丁合集

妙正灰 2017-05-15 10:44:38 284072浏览量 回答数 34

39

回答

安全组详解,新手必看教程

我的中国 2017-11-30 15:23:46 263743浏览量 回答数 39

295

回答

Linux Bash严重漏洞修复紧急通知(已全部给出最终修复方案)

qilu 2014-09-25 13:26:50 438554浏览量 回答数 295

251

回答

阿里云LNAMP(Linux + Nginx + Apache + MySQL + PHP)环境一键安装脚本

云代维 2014-02-14 15:26:06 310489浏览量 回答数 251

24

回答

【精品问答】python技术1000问(1)

问问小秘 2019-11-15 13:25:00 486577浏览量 回答数 24
+关注
落地花开啦
喜欢技术,喜欢努力的人
0
文章
7824
问答
问答排行榜
最热
最新
相关电子书
更多
JS零基础入门教程(上册)
立即下载
性能优化方法论
立即下载
手把手学习日志服务SLS,云启实验室实战指南
立即下载