Page 1 of 1

help with $_SERVER['HTTP_REFERER']

Posted: Fri Mar 07, 2003 12:41 pm
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

Posted: Fri Mar 07, 2003 1:27 pm
by daven
header("Location: $_SERVER['HTTP_REFERER']")

You forgot the quotes around the Location

Posted: Fri Mar 07, 2003 1:41 pm
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']);

Posted: Fri Mar 07, 2003 1:44 pm
by daven
Right. I need to proof-read my posts.

Stupid self.

Posted: Fri Mar 07, 2003 1:49 pm
by volka
happens all the time. The most important feature to me is "edit" at this board ;)

Thanks, but...

Posted: Fri Mar 07, 2003 2:12 pm
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: