es obvio que $cat existe si solo hay $_POST, de ahí el error.... si no hay POST no hay $cat !!!
¿como solucionarlo??
antes de alterar $cat declaralo al inicio, como array.... así evitas el error!
Código PHP:
$cat = array();
// ....
foreach ($cat /* ... */)
¿listo??