Jump to content

Recommended Posts

Hi there. I hope you guys can help :)

This works on local host but once online it fails with "PHP Warning:  session_start(): Cannot start session when headers already sent in /home/martinsb/public_html/switcher/switch.php on line 10"

Here is the nav  part

<!---new code added for style switcher-->
 
Style is set to <?php echo $_SESSION["msg"];?><br/>
      
        <a class="<?php echo $_SESSION['look0'];?>" href="switcher/switch.php?set=default">Default</a>
        <a class="<?php echo $_SESSION['look1'];?>" href="switcher/switch.php?set=ada">ADA</a>
        <a class="<?php echo $_SESSION['look2'];?>" href="switcher/switch.php?set=burrito">Burrito</a><br/>
        <div style="font-size:12px; padding-top:8px; padding-bottom:10px;"><?php echo $_SESSION["why"];?></div>
        

<!--end switcher-->

 

Here is the switcher.php

<?php

    $part= $_SERVER['HTTP_REFERER'];
    $path_parts = pathinfo($part);
     $result = $path_parts['basename'];
    
    
session_start();

?>
<?php
if( !isset($_GET['set'])){
    echo "";
    }
    
elseif ($_GET['set']=='default') {
        
        $_SESSION["css"]="css/mysite.css";
        $_SESSION["msg"]="Default";
        
        
        }    

elseif ($_GET['set']=='dark') {
        
        $_SESSION["css"]="css/darkstyles.css";
        $_SESSION["msg"]="Dark";
        
        
        }
        
elseif($_GET['set']=='light')  {
        
        $_SESSION["css"]="css/lightstyles.css";
        $_SESSION["msg"]="Light";
    
        
        }
        
if   ( !isset($_SESSION["css"]) )
    {$_SESSION["css"]="css/mysite.css";
        $_SESSION["msg"]="Default";
    
        }
        
        
        
?>    
<?php
// 301 Moved Permanently

header("Location: ../$result", true, 301);

exit();
?>

Link to comment
https://forums.phpfreaks.com/topic/312337-css-switcher-works-local-but-not-online/
Share on other sites

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.