\r\n"; $result = mail("andrea.franceschini@gmail.com", "Website contact", $message, $headers); if($result == 1) { $ref = filter_var($_SERVER['HTTP_REFERER'], FILTER_SANITIZE_URL); session_start(); $_SESSION['contact_thanks'] = 1; header("Location: $ref"); }