Sostituisci

if($_POST["invia"])

con

if(isset($_POST["invia"]))