how can I prevent PHP from returning an Undefined variable error every time I try to check a variable if it has contents and that certain variable hasn\'t b
You could use the empty function, which returns true if the variable is either unset or empty (i.e. a zero-length string, 0, NULL, FALSE and so on):
if(!empty($_POST['variable'])){
/* ... */
}
This is pretty much the same test as the one you're doing now, except that it will also return false (not run the block), without warnings, when the variable is unset.