PHP / CSS issue? Template calling

Discussion in 'PHP' started by virulent, Mar 19, 2011.

  1. #1
    I had someone duplicate my old website back in the day, and I'm having issues with it. Unfortunately the person who did it is no longer active, so I cannot retreive his support.

    URL: http://www.helter.org


    Problem: When I click the themes at the bottom of the site, they don't change unless I actually hit f5 to refresh the page. I want them to change accordingly when clicked to the proper .css - Even sometimes when I refresh they screw up and load like half a blue template and half a grey? I don't get what is wrong, and could use some help! Thanks! :)
     
    virulent, Mar 19, 2011 IP
  2. virulent

    virulent Well-Known Member

    Messages:
    231
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #2
    Assuming it's a cache problem, I fixed the half blue half grey problem, just need to fix the other problem still...any help?
     
    virulent, Mar 19, 2011 IP
  3. artus.systems

    artus.systems Well-Known Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    103
    #3
    show the code on your index.php file
     
    artus.systems, Mar 20, 2011 IP
  4. virulent

    virulent Well-Known Member

    Messages:
    231
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #4
    <?
    session_start();
    if(isset($_GET['shade']))
    {
    	$_SESSION['shade']=$_GET['shade'];
    	header("Location: ".$_SERVER['HTTP_REFERER']);
    }
    if($_SESSION['shade']=="")
    {
    	$_SESSION['shade']="yellow";
    }
    //echo $_SESSION['shade']."<br>";
    ?>
    
    <html><head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <!-- base href="http://www.craq.org/" -->
    <title>CraQ [dot] Org</title><link rel="stylesheet" type="text/css" href="styles/index-<?=$_SESSION['shade']?>.css"><title>CraQ [dot] Org</title></head><body class="index-body" topmargin="0" leftmargin="0" rightmargin="0" bottommargin="0" background="CraQ%20%5Bdot%5D%20Org_files/a.htm">
    
    <table class="tables" id="table1" cellspacing="0" width="100%" height="100%">
    	<tbody><tr>
    		<td class="top-table" colspan="1" align="left" valign="top" height="21"><b>IP</b>: <?=$_SERVER['REMOTE_ADDR']?></td>
    		<td class="top-table" colspan="3" align="right" valign="top" height="21">Welcome to <b>http://craq.org</b></td>
    	</tr>
    	<tr>
    		<td colspan="3" valign="top" height="20%">
    		</td>
    	</tr>
    	<tr>
    		<td valign="top" width="19%">&nbsp;</td>
    		<td valign="top" width="62%">
    		<center><font size="4"><a href="main.php"><img src="images/splash-<?=$_SESSION['shade']?>.jpg" border="0" width="400" height="400"></a>
    		</font>
    		</center></td>
    		<td valign="top" width="19%">&nbsp;</td>
    	</tr>
    	<tr>
    		<td colspan="3" valign="top" height="20%">
    		</td>
    	</tr>
    	<tr>
    		<td class="bottom-table" colspan="3" valign="top" height="81">
    		<center>
    		Themes<br><br>
    		<a href="index.php?shade=yellow"><img src="images/yellow.jpg" border="0" width="50" height="50"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;		
    		<a href="index.php?shade=grey"><img src="images/grey.jpg" border="0" width="50" height="50"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    		<a href="index.php?shade=blue"><img src="images/blue.jpg" border="0" width="50" height="50"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    		<a href="index.php?shade=purple"><img src="images/purple.jpg" border="0" width="50" height="50"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    		<a href="index.php?shade=teal"><img src="images/teal.jpg" border="0" width="50" height="50"></a>
    
    		</center></td>
    	</tr>
    </tbody></table>
    </body></html>
    Code (markup):
     
    virulent, Mar 20, 2011 IP
  5. artus.systems

    artus.systems Well-Known Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    103
    #5
    artus.systems, Mar 20, 2011 IP
  6. virulent

    virulent Well-Known Member

    Messages:
    231
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #6
    That seemed to work great! Thanks! May i ask how you did it? I'm assuming this line you changed?

    
    <link rel="stylesheet" type="text/css" href="styles/index-<?php echo $_SESSION['shade']?>.css">
    Code (markup):
    If there was anything else please let me know for future reference!
     
    virulent, Mar 20, 2011 IP
  7. artus.systems

    artus.systems Well-Known Member

    Messages:
    87
    Likes Received:
    1
    Best Answers:
    1
    Trophy Points:
    103
    #7
    Changed the php code,
    removed the header redirect then checked if session(shade) isset, if not applied default css yello
    <?php
    session_start();
    if(isset($_GET['shade']))
    {
    	$_SESSION['shade']=$_GET['shade'];
    
    }
    if(empty($_SESSION['shade']) || (!isset($_SESSION['shade']))) // here
    {
    	$_SESSION['shade']="yellow";
    }
    //echo $_SESSION['shade']."<br>";
    ?>
    Code (markup):
    and here, removed the short tag for php <? and replaced with php long tag <?php (recommended)
    <?php echo $_SESSION['shade']?>
    Code (markup):
     
    artus.systems, Mar 20, 2011 IP
  8. vediovis

    vediovis Peon

    Messages:
    35
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    long tags are recommended only in case you move your script on a server where short tags are not activated.

    If you work in a non moving project with a current hosting solution, there's nothing wrong using short tags. It s quite handy for perl like tests and echo =.
     
    vediovis, Mar 22, 2011 IP