不使用表单,是否可以_POST到另一个文件?
就我而言,我想通过_POST将字符串发送到该文件。
感谢。
更新
根据对我帖子的回复,我使用了这个:
<?php
$ipCreation = $_SERVER['REMOTE_ADDR'];
$ipCreationCurl = curl_init(); // initiate curl
$url = "accountcreation.php"; // where you want to post data
curl_setopt($ipCreationCurl, CURLOPT_URL,$url);
curl_setopt($ipCreationCurl, CURLOPT_POST, true); // tell curl you want to post something
curl_setopt($ipCreationCurl, CURLOPT_POSTFIELDS, $ipCreation); // define what you want to post
curl_setopt($ipCreationCurl, CURLOPT_RETURNTRANSFER, true); // return the output in string format
$output = curl_exec ($ipCreationCurl); // execute
curl_close ($ipCreationCurl); // close curl handle
var_dump($output); // show output
?>
返回:
&#34; 308永久移动&#34;
我的错误是什么?感谢。
答案 0 :(得分:0)
您可以使用curl发布。以下是一个基本示例:http://devzone.co.in/post-data-using-curl-in-php-a-simple-example/
$ch = curl_init(); // initiate curl
$url = "http://www.somesite.com/curl_example.php"; // where you want to post data
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, true); // tell curl you want to post something
curl_setopt($ch, CURLOPT_POSTFIELDS, "var1=value1&var2=value2&var_n=value_n"); // define what you want to post
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in string format
$output = curl_exec ($ch); // execute
curl_close ($ch); // close curl handle
var_dump($output); // show output