you cannot mix JS and PHP.
To explain this in a bit more detail, this is how a PHP page works:
- A browser sends a request to a server, to receive a PHP page.
- The server executes the PHP, creating a webpage, usually made up of HTML, CSS and Javascript content.
- The server sends the content created by PHP to the browser.
- The browser displays the HTML and CSS, and executes the JavaScript code.
So, you see, a
header call (which is a PHP function), is always executed before any JavaScript code, like the
alert function. If you need the client-side code (JavaScript) to redirect the page, use the method Dormilich described in hist last post. If you need PHP to redirect, use the
header function. You can, however, not mix the two methods, because they aren't even being executed by the same computer.