the way that a link is opened has to do with your HTML, NOT with PHP. your php is completely parsed before the browser ever sees your page. with that in mind, you need to check your <a> tags that are causing this issue, and make sure you're not declaring a target attribute different from the current window.