2010-12-22 136 views
0

IM的bizzare和計算器即時通訊新的,我有一些問題,這就是:捲曲POST數據問題

IM直接正確地將一些頁面,一個頁面,頁面回答了我的要求,但我在嘗試發送POST數據使用cURL通過PHP的頁面沒有任何地方反應:

<form action="http://remotehost.com/index.aspx" method="post"> -> its work correctly and the index.php show me what i want but when : 

<form action ="http://localhost/fetch_data.php" mthod="post"> -> 

fetch_data.php: 
<html> 
<head> 
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"> 
<?php 
print_r($_POST); 
$remotehost_cgi = 'http://remotehost.com/index.aspx'; 
$ret = post_data($_POST, $remotehost_cgi); 
echo $ret; 



?> 

<?php 
function post_data($datatopost,$urltopost){ 
$crl = curl_init ($urltopost); 
curl_setopt ($crl, CURLOPT_POST, true); 
curl_setopt ($crl, CURLOPT_POSTFIELDS, $datatopost); 
curl_setopt ($crl, CURLOPT_RETURNTRANSFER, true); 
$returndata = curl_exec ($crl); 
return $returndata; 
} 
?> 

回答

1

mthod="post"method="post"

+0

:-j好的!!!!!方法=「發佈」 – BobAlexy 2010-12-23 00:03:58

+1

現在按左邊的複選標記:) – 2010-12-23 00:07:58

0

curl_exec()返回布爾值如果exec由於任何原因失敗返回布爾值。而不是僅僅返回你的$returndata,先測試一下:

... 
$returndata = curl_exec($crl); 
if ($returndata === FALSE) { 
    die('Curl failed: ' . curl_error($crl)); 
} 
return($returndata); 

既然你只能隨聲附和了這個值,那就永遠看不到它,因爲布爾值false將輸出爲空/空字符串。