这是我的代码:
if (isset($_POST['addmonths'])){
if (!empty($_POST['months'])){
if (is_numeric($_POST['months'])){
$monthtoadd = $_POST['months'];
if ($monthstoadd == 0){
mysql_query("UPDATE users SET months='lifetime' WHERE username='$lookupuser'");
echo "Successfully set " . $lookupuser . " to lifetime" . $monthstoadd;
}elseif ($monthstoadd > 0){
$monthstoadd = $monthstoadd*2592000;
mysql_query("UPDATE users SET months=months+'$monthstoadd' WHERE username='$lookupuser'");
echo "Successfully added " . $monthstoadd . " months to " . $lookupuser . "'s paid time.";
}else{
echo "Error.";
}
}else{
echo "Months need to be numeric. If you're trying to set lifetime, use 0.";
}
}else{
echo "You didn't enter anything.";
}
}
无论我输入的是什么号码,它似乎总是将其设置为生命周期,然后它不会回显$monthstoadd
后面的那个,这就是帮助我看看为什么它不起作用。我无法想象我的生活。如果我没有输入任何东西,它会像它应该的那样回复You didn't enter anything.
,如果它不是数字,它就像它应该的那样回应Months need to be numeric. If you're trying to set lifetime, use 0.
。
有人有什么想法吗?
答案 0 :(得分:6)
第4行:
$monthtoadd = $_POST['months'];
应该是$ monthstoadd(注意缺失的s)
答案 1 :(得分:6)
$monthtoadd = $_POST['months'];
应该是
$monthstoadd = $_POST['months'];