Is there a PHP redirect that will open a new window?

Currently I’m using <? header(“location: http://www.mysite.com”); ?> for the redirect but now I need it to pop up a new window when it redirects. Does anyone know if this is possible and how its done?

PHP is server-side. A new pop-up window is client-side. The most common way of doing this is with either the target=“_blank” attribute in a link, or with javascript using window()

Thanks for the fast reply. So what your saying is there is no way of doing it with the PHP code I’m using now? In other words there is no way of adding target=“_blank” to the page with the script I’m using? Sorry I’m a Noob and I don’t really understand this yet.

PHP CANNOT open a new window. It CANNOT control client side behaviour.

<?php header(“location: http://www.mysite.com/index.php”); ?>

<?php header(“location: http://www.mysite.com/index.php?pop=yes”); ?>

You could optionally tell the target php page to call a JS function to open the page, but is that what you meant?


//index.php
<head>
<?php

if( isset($_GET['pop'] ){

//do your js here, example:
echo 'window.open("page2.php", $other_Attributes_here )';

}

?></head>

<?php header(“location: http://www.mysite.com/index.php?pop=yes”); ?>

Thanks cups!!!:slight_smile: I looked everywhere for something that would work and you nailed it. Works like a charm.

shock that two thank you’s for me on one day!

So nice of you to reply :slight_smile: