Jump to content

Cart will only allow for one template trying to use PHP to solve problem


new2php1033

Recommended Posts

Hi Everyone,

 

I am still learning php but tried to write something to solve a problem I am having. A cart that I need to use will only allow for their template but it hooks into our POS system so I need to use it. It uses the same divs for both the inner page and home page making it harder to style. What I wanted to do since I can upload multiple stylesheets is try and use a if statement and say if it is the index.html page show this style sheet else show the standard inner page. Can someone tell me what I did wrong.

 

<?php if ( $_SERVER[sERVER_NAME] == "https://domain.com/index.htm" ){

echo '<link rel="stylesheet" href="graphics/styleshome.css" type="text/css" />';

}else{

echo '<link rel="stylesheet" href="graphics/styles.css" type="text/css" />';

}

?>

 

Thanks

$_SERVER['SERVER_NAME'] will only give you the domain

you probably want $_SERVER["PHP_SELF"],

 

Quick tip

add this line of code

echo "<!-- This file is:".$_SERVER["PHP_SELF"]." -->";

and load up the first template, and view source and look for 'This file is' copy the text after it, and use that in your statement ;)

 

also remember the $_GET maybe used to pick the page, ie ?page=home, you could use that instead ie

if ($_GET['page'] == 'home')

Archived

This topic is now archived and is closed to further replies.

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