PHP page redirection using javascript

little problem! I have a PHP file entry form. I used javascript validation for the form. In a successful login scenario, I redirect the user to my home page.

I used header("Location:index.php") .

I know that the header should be before any output should be sent to the browser. My question is: is there any walk to do this redirect?

+4
source share
4 answers

you can use

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

to redirect after sending headers.

+15
source

Besides using header() for redirection, you can use the meta-processing method or the JS window.location method.

+1
source

If you are ready to use JavaScript, you can use any of the following methods.

 1.window.location.assign('http://www.example.com'); 2.window.location = 'http://www.example.com'; 3.window.location.href = 'http://www.example.com'; 
+1
source

If you use javascript use this

 window.location.href = "index.php"; 
0
source

All Articles