我在用一段代码苦苦挣扎。我已经知道此代码存在错误。它使用cURL。卷曲过程完美地工作,但是我添加了一个if语句来检查逻辑,以便将某些变量传递给其他服务器。提前致谢..
<?php
include("../config.php");
if ( !isset( $_COOKIE['admin'] ) ) {
include_once("login.php");
echo ("<div id='quote'>Error: Can not access page.");
}
else {
if (isset($_GET['user']) && ($_GET['user'] != "") && isset($_GET['licence']) && ($_GET['licence'] != "") &&
isset($_GET['to']) && ($_GET['to'] != "") && ($_GET['username'] !=
"")) {
$username = $_GET["username"];
$idlisc= $_GET["user"];
$licence = $_GET["licence"];
$to = $_GET["to"];
$acc = new Account;
$acc->changeVis($idlisc, $licence, $to);
header("Location: search.php?user=".$username);
if ($get["lic_".$i.] == 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18 || 19 || 20) {
$ch = curl_init(); //http post to another server
curl_setopt($ch, CURLOPT_URL,"http://xxx/add-user");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"codes=$licence");
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
print_r($server_output);
curl_close ($ch);
}
else {
$ch = curl_init(); //http post to another server
curl_setopt($ch, CURLOPT_URL,"http://xxx/add-user");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
"usr=$username&code=$licence&password=$id");
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
print_r($server_output);
curl_close ($ch);
}
}
您有两个语法错误
if ($_get["lic_".$i.]
-------------^ // Remove this dot
其次,您需要在代码末尾加一个大括号
curl_close ($ch);
}
}
} //<---- Add a brace here
编辑 :
检查您的if
陈述是否像这样
if ($_get["lic_".$i] == 11 || 12 || 13 || 14 || 15 || 16 || 17 || 18 || 19 || 20)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句