我们的网站上有一个系统,您可以在其中拥有多个帐户并在每个帐户上赚取积分。你可以在我注意到错误的这个网页上的账户之间转移的积分。基本上,如果我有某个账户组合,即第一个和第二个,它不会让我转移,只会说"请填写一个数字。"。如果我有第一个、第三个或全部三个,它会很好。我已经看了大约两个小时了,找不到不起作用的东西。。。如有任何帮助,我们将不胜感激: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");
}
}
}
?>
在这里的代码中,您正在建立几个变量。
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的值。首先将其移动到一个函数中,然后从那里开始。