0

我们的网站上有一个系统,您可以在其中拥有多个帐户并在每个帐户上赚取积分。您可以在我发现错误的此网页上的帐户之间转移的那些积分。基本上,如果我有一定的账户组合,即第一和第二,它不会让我转账,它只会说“请填写一个数字。”。如果我有第一个和第三个或所有三个,它工作正常。我已经浏览了大约两个小时,但找不到什么不起作用......任何帮助都将不胜感激:D

  <?php if($a == "exchange")

  {
  $GetUserInfo = mysql_query("SELECT * FROM members WHERE id = '$userid'") or die(mysql_error());

    $GetUserInfo = mysql_fetch_object($GetUserInfo);

    $cols = 1; //determines colspan
    $status = 1;

    $GetMultipleInfo = mysql_query("SELECT * FROM members WHERE id = '".$GetUserInfo->mult_uid."'") or die(mysql_error());  
      if(mysql_num_rows($GetMultipleInfo) != 0)
      {
        ++$cols;
        ++$status;
      }
      $GetMultipleInfo = mysql_fetch_object($GetMultipleInfo);



    $GetAdMultipleInfo = mysql_query("SELECT * FROM members WHERE id = '".$GetUserInfo->mult_admin."'") or die(mysql_error());
      if(mysql_num_rows($GetAdMultipleInfo) != 0)
      {
        ++$cols;
        $status = ($status == 2 ? 4 : 3);
      }
      $GetAdMultipleInfo = mysql_fetch_object($GetAdMultipleInfo);


// Sparks Transfer
if (isset($_POST['spartrans']))
{
  $order = $_POST['sparrecipients'];

if ($order == 'first')
{
  $tpoints2 = $_POST['tpoints2'];
  $tpoints3 = $_POST['tpoints3'];
  $tpoints = $tpoints2 + $tpoints3;

   if ($status == 2)
      if ((!is_numeric($tpoints1)) || (!is_numeric($tpoints2)) || empty($tpoints1) ||  empty($tpoints2))
        message("Please fill in with a number.","Enchanted Hogwarts","$PHP_SELF?a=exchange");
  elseif ($status == 3)
      if ((!is_numeric($tpoints1)) || (!is_numeric($tpoints3)) || empty($tpoints1) || empty($tpoints3))
        message("Please fill in with a number.","Enchanted Hogwarts","$PHP_SELF?a=exchange");
  elseif ($status == 4)
      if ((!is_numeric($tpoints1)) || (!is_numeric($tpoints2)) || (!is_numeric($tpoints3)) || empty($tpoints1)  ||  empty($tpoints2) || empty($tpoints3))
        message("Please fill in with a number.","Enchanted Hogwarts","$PHP_SELF?a=exchange");

  if ($tpoints2 > $GetMultipleInfo->tpoints)
    message("" . getName($GetMultipleInfo->id) . " does not have enough sparks.","Enchanted Hogwarts","$PHP_SELF?a=exchange");

  if ($tpoints3 > $GetAdMultipleInfo->tpoints)
    message("" . getName($GetAdMultipleInfo->id) . " does not have enough sparks.","Enchanted Hogwarts","$PHP_SELF?a=exchange");

  if ($GetUserInfo->mult_uid != 0)
    mysql_query("UPDATE members SET tpoints = GREATEST(tpoints - $tpoints2,0) WHERE id = '".$GetMultipleInfo->id."'") or die(mysql_error());
  if ($GetUserInfo->mult_admin != 0)
    mysql_query("UPDATE members SET tpoints = GREATEST(tpoints - $tpoints3,0) WHERE id = '".$GetAdMultipleInfo->id."'") or die(mysql_error());
  mysql_query("UPDATE members SET tpoints = GREATEST(tpoints + $tpoints,0) WHERE id = '$userid'") or die(mysql_error());

  message("Successfully transferred $tpoints Sparks to ".getName($userid).".","Enchanted Hogwarts","$PHP_SELF?a=exchange");
}

}

}
?>
4

1 回答 1

0

在您的代码中,您正在建立几个变量。

if ($order == 'first')
{
    $tpoints2 = $_POST['tpoints2'];
    $tpoints3 = $_POST['tpoints3'];
    $tpoints = $tpoints2 + $tpoints3;

但是在这里你正在检查不同变量的值。 $tpoints1从未建立。

if ((!is_numeric($tpoints1)) || (!is_numeric($tpoints2)) || empty($tpoints1) ||  empty($tpoints2))
          message("Please fill in with a number.","Enchanted Hogwarts","$PHP_SELF?a=exchange");

编辑:这可能是不正确的。您可能有 register_globals 将自动设置该变量。不推荐,但不是你问的问题。

最重要的是,您需要确定正在执行代码的哪个分支。根据您的描述,我的猜测是它是$order == 第一个分支,然后是$status == 3。但是,如果没有实际提交表格并且不知道做出了哪些选择,我就不可能说出来。而且所有的错误信息都是一样的“请填写一个数字”。不是很有帮助。

我个人会花时间重构你的一些代码。如果我不理解某些内容,我会将其分解成更小的块,直到我理解为止。否则,每次尝试找出问题时,您将始终在此页面中进行筛选。

$order 的每个选择都以完全相同的方式验证 $tpoints1、$tpoints2 和 $tpoints3 的值。首先将其移动到一个函数中,然后从那里开始。

于 2012-08-21T02:45:53.833 回答