help with $_SERVER['HTTP_REFERER']

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jon
Forum Newbie
Posts: 2
Joined: Fri Mar 07, 2003 12:41 pm

help with $_SERVER['HTTP_REFERER']

Post by jon »

I need help with a header. I'm linking to the script below to set a cookie and return to the refering page. I have:

Code: Select all

<?php
setcookie ('cookiename', $set, time()+31536000, '/', 'www.dom.com', '0');
header(Location: $_SERVER&#1111;'HTTP_REFERER']);
?>
But can't get it to work. I get the error:

Code: Select all

"Parse error: parse error, unexpected ':' ..."
I used to use

Code: Select all

header("Location: $HTTP_REFERER");
as the refer and it's worked for years, but now with increased security on our server I need to use the

Code: Select all

$_SERVER&#1111;'variable']
- something I'm having trouble getting my head around for some reason.

Any help is greatlt appreciated.

Jon
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

header("Location: $_SERVER['HTTP_REFERER']")

You forgot the quotes around the Location
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

this will raise a parse-error (something about encapsulated string). Instead try

Code: Select all

header("Location: $_SERVER[HTTP_REFERER]") ;
or

Code: Select all

header('Location: '.$_SERVER['HTTP_REFERER']);
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post by daven »

Right. I need to proof-read my posts.

Stupid self.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

happens all the time. The most important feature to me is "edit" at this board ;)
jon
Forum Newbie
Posts: 2
Joined: Fri Mar 07, 2003 12:41 pm

Thanks, but...

Post by jon »

That did it. My header works, but is there something new that I need to do with the setcookie () to get it to work? it's not writing the cookie.
:cry:
Post Reply