Here is my code:
if (isset($_POST['addmonths'])){
if (!empty($_POST['months'])){
if (is_numeric($_POST['months'])){
$monthstoadd = $_POST['months'];
if ($monthstoadd < 1){
mysql_query("UPDATE users SET months='lifetime' WHERE username='$lookupuser'");
echo "Successfully set " . $lookupuser . " to lifetime";
}elseif ($monthstoadd > 0){
$monthstoadd = $monthstoadd*2592000;
mysql_query("UPDATE users SET months=months+'$monthstoadd' WHERE username='$lookupuser'");
echo "Successfully added " . $_POST['months'] . " 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.";
}
}
When I enter 0, it should set the user to lifetime, but instead it just echos You didn't enter anything. Not really sure how to fix this. Any ideas?
You need to check the type to make sure it is empty instead of registers as empty with
===.if ($_POST['months'] !== ''){This checks to see if it exactly equivalent to empty. If it isn’t it passes.