Jump to content

redirecting


gos1

Recommended Posts

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

Hi

I 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]
hth

Neil
Link to comment
https://forums.phpfreaks.com/topic/30976-redirecting/#findComment-142921
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.