Return error when checkbox isn't checked PHP

I have been working on code for the last few days with some help and have 9 checkboxes that the user can check and it returns how much it will cost to use those services.

The problem I have run into is now when someone doesn’t check a box there are ton of errors generated and it looks unprofessional.

I have a variable called $values that I have set to 0 ($values=0) and the values change when the user hits submit. What I would like to do is generate a statement (using echo) if $values is still 0 at the end of the code but it is not working. I have tried empty() but I read not to use this with strings which I tried earlier with some other variables.

Here are the last few lines of my php code:
[php]

if ($value = 0) {
echo “Please choose one service.”;
}

if(in_array(‘a’ or ‘b’ or ‘c’ or ‘d’ or ‘e’ or ‘f’ or ‘g’ or ‘h’ or ‘i’, $services)) { // see which services are in the array and if so generate the following statement.

echo “The quote for the following service(s): " . implode(’, ', $service_list) . " will be a total of $” . number_format($value) . “.”;
}
}
[/php]

Update: I just checked trying to use an if/else statement but that doesn’t work either. The message displays “Choose a textbox” however all the other errors show first.

Thanks in advance.

You haven’t provided any code that has to do with the processing of the form. Also that is not how in_array() works.

Sponsor our Newsletter | Privacy Policy | Terms of Service