Reputation: 8101
Here is my code:
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.";
}
}
No matter what number I enter, it always seems to set it to lifetime, and then it doesn't echo the $monthstoadd
after it, which is just there to help me see why it's not working. I can't figure this out for the life of me. If I don't enter anything, it echos You didn't enter anything.
like its supposed to, and if its not a number, it echos Months need to be numeric. If you're trying to set lifetime, use 0.
like its supposed to.
Anyone have any ideas?
Upvotes: 1
Views: 126
Reputation: 10377
$monthtoadd = $_POST['months'];
should be
$monthstoadd = $_POST['months'];
Upvotes: 6
Reputation: 523
Line 4:
$monthtoadd = $_POST['months'];
Should be $monthstoadd (note the missing s)
Upvotes: 6