Invalid URI msg

I’ve been having a horriable time trying to get a page to redirect using a header()

my code:

if(isset($_COOKIE[‘refurl’])){
header(“Location: /”.$_COOKIE[‘refurl’]);
exit();
}

when it executes it gives me and “Invalid URI” error and the address bar of the pages looks like this:

http://www.MyHomepage.com/www.MyHomepage.com/articles/article1

When I take out the / at “Location : /” it does this endlessly:

http://www.MyHomepage.com/www.MyHomepage.com/articles/article1www.MyHomepage.com/articles/www.MyHomepage.com/articles/
http://www.MyHomepage.com/articles/www.MyHomepage.com/articles/ etc.

I’ve used all my brain power on this problem, and I just don’t know what to do.
Any help is greatly appreciated.

http://www.MyHomepage.com/www.MyHomepage.com/articles/article1

Looks like you’re forgetting about the http:// part:

header("Location: http://".$_COOKIE['refurl']);

Btw, don’t trust user input (cookies) like that. Test its value to make sure it’s valid.

Sponsor our Newsletter | Privacy Policy | Terms of Service