How do I open a new Web page from within PHP?

Greetings,

How do I open a new Web page from within PHP?

I mean I am using

header("Location: $url );

to send the user to the desired web page, but when I do it like this:

header("Location: $url  target=\\"new\\"");

it does not work. That is it does not open the desired $url in a new web page.

Regards,

The “header” method would redirect a person before a page loads on their screen normally so in what context are you trying to do this?

Maybe JavaScript would be more suited to your needs. If you need to communicate with a server-side script to get $url then you should use Ajax.

I think what you are trying to say is that you want to re-direct to open in a new window. Is that correct?

You cannot open a new window / new tab using PHP. You must use Javascript to do that. And in the year 2008, it will most-likely be blocked by pop-up blocker.

You will have to use a URL and have the person click on it.


<a href="new_page.php" target="_new">Continue to next page</a>

Hi,

Simply put, I want to direct the user to the resulting page, based on whatever
choice they have made, and have this new web page open in a new web browser than into the existing browser page from which they made the selection.

Regards,

Yes.

Well of course I know of this as an option, but I was trying/hoping that there
was a more elegant solution for this task, a PHP based solution.

Regards,

I don’t see what’s so inelegant about html code. After all, that’s what it’s for!

PHP isn’t meant to deal with client side functionality (outside of AJAX I guess)…

Well Ok then.
So if there is no way of doing this with PHP so I guess I will use HTML (JScript) to do it. At least I tried :slight_smile:

But FYI, JSP allows for this, and sometimes it is best if not a must that such redirecting of content into a new web browser page should be done by code that was executed server side.

Regards,

The problem isn’t having PHP return a different page, as this falls within the realm of server-side. The problem is opening a new browser window, which is client-side. I imagine the JSP code you are referring to uses javascript (or some flavor of ECMA) to do so.