Maison >développement back-end >tutoriel php >模拟表单提交的例子_PHP教程

模拟表单提交的例子_PHP教程

WBOY
WBOYoriginal
2016-07-13 17:12:33971parcourir

// simple post method
// version 1.0 by Andrus (andrus@vnet.ee)
// 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);

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/629390.htmlTechArticle?php // simple post method // version 1.0 by Andrus (andrus@vnet.ee) // Disclaimer: // everyone can change or use this code however and wherever they want ;) // NB! For posting to M...
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn