Huster Huster - 5 days ago 6
PHP Question

php using header to Redirect

I m new on php stuff so execuse me for any confusing terms.
I have a form on a page with a button that once clicked it pops up another sub page:

onclick="newPopup('page2.php','750','500')"


page2.php has another button, I want to be able to redirect the Main Page to another url using this popup.

Answer

If you want to redirect the main page on a button click in the popup, you need to do this with JS, not PHP.

Add this to the button in the popup:

onclick="window.opener.location.href='someurl.php'";

From a popup, you can access the page/window that opened the popup with: window.opener. This means that you also can call functions on the main page: window.opener.someFunctionOnTheMainPage().

Comments