[英]cUrl not sending POST data php
我在cURL上看到我的代碼有問題
www.example1.com/index.php
$Email = $_POST['Email'];
$Password = $_POST['Password'];
$sql = $dbh->prepare('SELECT * FROM users WHERE Email = ? AND Password = ?');
$sql->execute(array($Email,$Password));
if($sql->rowCount() == 1) {
$data = array('Found'=> 'Great');
$string = http_build_query($data);
$ch = curl_init("http://www.example2.com/index.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
}else{
$data = array('Found'=> 'Sorry');
$string = http_build_query($data);
$ch = curl_init("http://www.example2.com/index.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
}
www.example2.com/index.php
$data = array('Email'=>'Email@Example.com', 'Password'=>'Password');
$string = http_build_query($data);
$ch = curl_init("http://www.example1.com/index.php");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
curl_close($ch);
if(isset($_POST['Found'])) {
$Found = $_POST['Found'];
echo $Found;
}
它沒有在www.example2.com中回顯任何內容,所以我該怎么辦,我可以回顯Found變量。
對不起,我的英語不好,我希望你能理解我,謝謝:)
嘗試將curl的輸出保存到這樣的變量中:
$Found = curl_exec($ch);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.