我正在努力处理一段代码。我已经知道了 此代码出错。它使用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);
}
}
答案 0 :(得分:3)
你有两个语法错误
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)