Forse puoi usare $_SERVER['PHP_SELF'] per fare operazioni nella stessa pagina.