gos1 Posted December 17, 2006 Share Posted December 17, 2006 Hi ; I have a problem while redirecting user to another page. When I use [code]header("Location:admin.php");[/code] I first got an error message headers already sent. Then deleted the empty lines and now nothing happens. Then I tried to echo the javascript code: [code]window.location = 'admin.php'[/code]and it does not work on my page because I dont have headers and footers in my page. How can I redirect the user to another page ? ?? Link to comment https://forums.phpfreaks.com/topic/30976-redirecting/ Share on other sites More sharing options...
NovaHaCker Posted December 17, 2006 Share Posted December 17, 2006 When you use header, you must ensure that nothing has been written to the document at all, otherwise the header command will return that error.Hope this helps. Link to comment https://forums.phpfreaks.com/topic/30976-redirecting/#findComment-142920 Share on other sites More sharing options...
Simmo Posted December 17, 2006 Share Posted December 17, 2006 HiI use this code [code]$url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } $url .= '/new_page.php'; // Add the page. header("Location: $url"); mysql_close(); exit();[/code]hthNeil Link to comment https://forums.phpfreaks.com/topic/30976-redirecting/#findComment-142921 Share on other sites More sharing options...
gos1 Posted December 17, 2006 Author Share Posted December 17, 2006 I decided to use javascript for that. It works fine and does not require an empty page Link to comment https://forums.phpfreaks.com/topic/30976-redirecting/#findComment-142953 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.