当前位置:Gxlcms > PHP教程 > html-php文件无法得到POST过来的数据

html-php文件无法得到POST过来的数据

时间:2021-07-01 10:21:17 帮助过:2人阅读

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数据的模板

    

    
        
        

        

    

    

        
            
  • 管理单元

回复内容:

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数据的模板

    

    
        
        

        

    

    

        
            
  • 管理单元

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

人气教程排行