Jump to content

Recommended Posts

Hello,

I have a simple style switcher on my website which worked nicely.

My hosting company have switched to php5 and now the style switcher no longer works.

 

the code is from the A List Apart website:

 

<?php

setcookie ('sitestyle', $set, time()+31536000,

'/','my domain', '0');

header("Location: $HTTP_REFERER");

?>

 

 

 

<link rel="stylesheet" type="text/css"

media="screen" title="User

Defined Style" href="<?php echo

(!$sitestyle)?'defaultstyle':$sitestyle ?>.css" />

 

 

Is there a way to make this code "php5 compatible"?

 

Many thanks to anyone who offers a suggestion.

 

 

 

Merry Christmas to everyone on the forum.

Link to comment
https://forums.phpfreaks.com/topic/82660-php-style-switcher-help/
Share on other sites

The code does need the exit; statement to prevent the rest of the code from being executed and output while the browser executes the redirect, but that is not the real problem.

 

The code is dependent on register_globals being on and is not php5 problem.

 

$HTTP_REFERER only exists when register_globals are on (check your web server log file for an undefined notice or warning message about $HTTP_REFERER)

 

Change the line to -

 

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

The code does need the exit; statement to prevent the rest of the code from being executed and output while the browser executes the redirect, but that is not the real problem.

 

The code is dependent on register_globals being on and is not php5 problem.

 

$HTTP_REFERER only exists when register_globals are on (check your web server log file for an undefined notice or warning message about $HTTP_REFERER)

 

Change the line to -

 

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

 

Thanks  r-it & PFMaBiSmAd.

 

I changed the .htaccess file to have register_globals on and that did the trick!

 

So I guess php5 has register_globals off by default or else the hosting company has them off for security reasons??

 

I also changed my code to reflect the suggestions offered, but that didn't work!?

 

When I went back to my original code, it worked!?

 

Thanks for your help....I can go out and have some beers now!  CHEERS!  :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.