kathir Posted March 19, 2014 Share Posted March 19, 2014 Dear Friends, Simple header in php not working. I'm Using XAMPP 1.8.2, PHP 5.4.22.I dont know this simple header function not working. Please HELPPPP.. I have already tried the following codes. <?php header('Location:http://www.google.com'); ?> Is there any other problems with php.ini file or something?. Please i need help. Quote Link to comment https://forums.phpfreaks.com/topic/287099-simple-header-not-working-in-php-helppppp/ Share on other sites More sharing options...
Psycho Posted March 19, 2014 Share Posted March 19, 2014 What is happening? Are you getting any errors? Quote Link to comment https://forums.phpfreaks.com/topic/287099-simple-header-not-working-in-php-helppppp/#findComment-1473211 Share on other sites More sharing options...
Solution Crew-Portal Posted March 19, 2014 Solution Share Posted March 19, 2014 (edited) <?php header('Location: http://google.com/'); echo " <script type=\"text/javascript\"> <!-- window.location = \"http://google.com/\" //--> </script>"; die("Unknown Error"); ?> Make sure this is at the VERY top of your page. Before any HTML gets outputted to the browser. This will try to use PHP for the redirect, if it fails it will attempt Javascript for redirect, if Javascript also fails (or is turned off in the user client) it will cause an error page to load. Edited March 19, 2014 by Crew-Portal Quote Link to comment https://forums.phpfreaks.com/topic/287099-simple-header-not-working-in-php-helppppp/#findComment-1473214 Share on other sites More sharing options...
gizmola Posted March 19, 2014 Share Posted March 19, 2014 Make sure that you don't have any whitespace above the opening php tag. Also how are you attempting to run this script? Are you using http://localhost/yourscript.php? Quote Link to comment https://forums.phpfreaks.com/topic/287099-simple-header-not-working-in-php-helppppp/#findComment-1473215 Share on other sites More sharing options...
kathir Posted March 20, 2014 Author Share Posted March 20, 2014 What is happening? Are you getting any errors? It displays empty page. But now its solved. Thanks for you kind reply.. Quote Link to comment https://forums.phpfreaks.com/topic/287099-simple-header-not-working-in-php-helppppp/#findComment-1473251 Share on other sites More sharing options...
kathir Posted March 20, 2014 Author Share Posted March 20, 2014 Make sure that you don't have any whitespace above the opening php tag. Also how are you attempting to run this script? Are you using http://localhost/yourscript.php? Yes i used to run the script with http://localhost/yourscript.php . Now its solved. Thanks for your kind reply. Quote Link to comment https://forums.phpfreaks.com/topic/287099-simple-header-not-working-in-php-helppppp/#findComment-1473252 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.