Correct, an object can be
set and still be empty, but if it's not set, you'll get an undefined index when checking for empty. :-) So check for isset.
$rad = $_POST['rad'];
if(isset($rad) && $rad != ""){ ...
The small error here is you will get an "undefined index" error if there are no radios checked (see "soapbox" below.) You want to check post:
$rad = isset($_POST['rad']))?$_POST['rad']:NULL;
if ($rad) { .......
but when I use that for radio and checkboxes if the user does not check the checkbox or radio button then php will show errors
Checkboxes are easy. Checked = isset, not checked it won't be set.
<soapbox>
I get this request from clients all the time: "can we make it so
NO radio buttons are checked when it loads, so they have to select one?" This is an abuse of the radio button;
one should always be checked by default. I usually manage to convince them that if they want to use this functionality, a checkbox or select is more appropriate.
Second, having "no radios checked" makes your job more difficult. If one is checked by default - which is how they are supposed to work - you can always count on it being set. It also makes your progressive Javascript validation more difficult, you now have to add JS to make sure at least one is checked, when you otherwise wouldn't.
If it's one of the situations where you need to
make sure they made that choice without overlooking it, don't use a radio button.
</soapbox>