


Detailed explanation of 2 methods of php simulating POST submission_PHP tutorial
1. Copy the code through the curl function
$post_data = array();
$post_data['clientname'] = "test08";
$post_data['clientpasswd'] = "test08";
$post_data['submit'] = "submit";
$url='http://xxx.xxx.xxx.xx/xx/xxx/top.php';
$o="";
foreach ($post_data as $ k=>$v)
{
$o.= "$k=".urlencode($v)."&";
}
$post_data=substr($o,0 ,-1);
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL ,$url);
//In order to support cookies
curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$result = curl_exec($ch);
2. Copy the code through fsockopen
$post_data['clientpasswd'] = "test08";
$post_data['submit'] = "ログイン";
$referrer="";
// parsing the given URL
$URL_Info=parse_url($URL);
// Building referrer
if($referrer=="") // if not given use this script as referrer
$referrer=< PRE class=php name="code">{1}
SERVER["SCRIPT_URI"]; // making string from $dataforeach($post_data as $key=>$ value)$values[]="$key=".urlencode($value); $data_string=implode("&",$values);// Find out which port is needed - if not given use standard (=80) if(!isset($URL_Info["port"]))$URL_Info["port"]=80;//
building POST-request:$request.="POST ".$URL_Info["path"]. " HTTP/1.1n";$request.="Host: ".$URL_Info["host"]."n";$request.="Referer: $referrern";$request.="Content-type: application/ x-www-form-urlencodedn";$request.="Content-length: ".strlen($data_string)."n";$request.="Connection:
closeen";$request.="n" ;$request.=$data_string."n";$fp = fsockopen($URL_Info["host"],$URL_Info["port"]);fputs($fp, $request);while(!feof($fp )) { $result .= fgets($fp, 128);}fclose($fp);
< /P>
Snoopy class (2)
sourceforge.net/projects/snoopy/
http://www.redalt. com/xref/trunk/nav.htm?wp-includes/class-snoopy.php.htm
HTTP class (1, 2)
PEAR HTTP_Request
http://pear.php.net/package/HTTP_Request
Popularity: 70%
http://www.bkjia.com/PHPjc/327596.html

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

Validator can be created by adding the following two lines in the controller.
