程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> 模擬表單提交的例子

模擬表單提交的例子

編輯:關於PHP編程

<?php
// simple post method
// version 1.0 by Andrus ([email protected])
// Disclaimer:
// everyone can change or use this code however and wherever they want ;)
// NB! For posting to Microsoft platform webservers you may need to change newlines " " to " "
// Microsoft always breaks standards ...
    // send out "browser" headers
    function send_headers ($fp) {
        fputs ($fp, "Accept: */* ");
        fputs ($fp, "Accept-Language: en ");
        fputs ($fp, "Connection: Keep-Alive ");
        fputs ($fp, "User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows 98) ");
    }
    // post data and return reply
    function post_data ($host, $url, $data) {
        $fp = @fsockopen ($host, 80, $errno, $errstr, 120);
        $ret = "";
           if (strncasecmp ($url, "http://", 7) == 0) $url = substr ($url, 7);
        $p = strpos ($url, '/');
        if (empty ($p)) {
       $req = "/";
        } else {
       $req = substr ($url, $p);
        }
        if ($fp) {
       fputs ($fp, "POST $req HTTP/1.0 ");
       send_headers ($fp);

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved