anshu anshu - 5 months ago 17
PHP Question

PHP Page redirection with javascript

a small problem ! I have a login form in a PHP file. I have used javascript validation for the form. On a login success scenario i am redirecting the user to their home page.

I have used

header("Location:index.php")
.

I know that the header must be before any output must be sent to the browser. My question is there any walk around to do this redirection?

Tom Tom
Answer Source

You could use

<script>
    window.location = 'http://www.example.com/newlocation';
</script>

to redirect after the headers are sent.