Ho scritto nell'ultima parte della risposta precedente $_POST['tipo']='usuario' in realtà volevo scrivere $_POST['tipo']='registrato'....