// $url should be an absolute url function redirect($url){ if (headers_sent()){ die(''); }else{ header('Location: ' . $url); die(); } }