我的first.php文件
$statusString = "u=10000;t1=1479409;s=10;r=-33;v=3.68;";
$macaddress= "10000";
$url = 'second.php';
$fields = array(
'newFormat'=>urlencode($statusString),
'MACAddress'=>urlencode($macaddress)
);
$fields_string = '';
foreach($fields as $key=>$value)
{
$fields_string .= $key.'='.$value.'&';
}
rtrim($fields_string,'&');
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);
这里我试图将数据从我的first.php发送到我的second.php
我的second.php文件
if (isset($_GET['newFormat']))
{
$str = $_GET['newFormat'];
}
else
$str = 'no data';
if (isset($_GET['MACAddress']))
{
$macAddress = $_GET['MACAddress'];
}
这里我试图检索first.php发送的数据。
我的first.php调用second.php,但是second.php无法检索任何数据。在我的second.php中,$ str结果是没有数据'就像在else部分和$ macAddress是空的!有人可以帮我解决这个问题吗?
答案 0 :(得分:0)
在second.php中,应该使用_POST而不是_GET